获取一个字典中的key,value值有多种方法,现总结一下,直接上代码:
dictss={'username': 'zhouchuanlun', 'code': '66666'}
# #获取key值,value值
for k,v in dictss.items():
print(k,v)
# #方法1:获取key值
for name in dictss.keys():
print(name.title())
# #方法2:获取key值
for name in dictss:
print(name)
# #方法1:获取value值
for v in dictss.values():
print(v)
# #方法2:获取value值
for v in dictss:
print(dictss[v])