使用keys()获取字典中的所有键

mydict={'a':1,'b':2,'c':3,'e':5}
a=mydict.keys()

print(a) #dict_keys(['a', 'b', 'c', 'e'])
print(type(a))#<class 'dict_keys'>
还能继续转成列表
print(list(a)) #['a', 'b', 'c', 'e']




 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-23
  • 2021-07-03
  • 2022-12-23
猜你喜欢
  • 2021-06-11
  • 2022-12-23
  • 2021-06-15
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案