以下方法等同,都可以获取key和value
1.#获取KEY和value
dir_test={ 'n':"psu",'v':"电压",'c':"电流"}
for key,value in dir_test.items():
print(key,value)
2#获取KEY和value
for i,j in dir_test.items():
#print("key:%s"%i,"value:%s"%dir_test[i])
print("key:%s"%i,"value:%s"%j)


#获取value
for value in dir_test.values():
print(value)
#获取key
for key in dir_test.keys():
print(key)

相关文章:

  • 2021-09-10
  • 2021-09-27
  • 2022-03-04
  • 2022-02-19
  • 2021-11-26
  • 2022-02-22
  • 2021-06-06
猜你喜欢
  • 2021-06-07
  • 2021-12-20
  • 2021-05-23
  • 2021-08-25
  • 2021-08-31
  • 2021-10-16
  • 2021-09-14
相关资源
相似解决方案