[英]How to get the values individually in a dictionary
我的字典中有这个,我需要单独获取我的值,例如日期是格林威治标准时间 2021 年 3 月 5 日 06:49:10。比如如何单独打印值。请帮我解决这个问题?
dict = {'Ernst & Young Nederland LLP': ['Mar 5 06:49:10 2021 GMT', '2048']}
You can iterate your dictionary and pick only the first value:您可以迭代您的字典并仅选择第一个值:
d = {'Ernst & Young Nederland LLP': ['Mar 5 06:49:10 2021 GMT', '2048']}
for v in d.values(): print(v[0])
If you need also they keys replace .values()
with .items()
like so:如果您还需要它们的键将.values()
替换为.values()
, .items()
所示:
for k,v in d.items():...
This will give the following output:这将提供以下输出:
Mar 5 06:49:10 2021 GMT
Iterate over the dict values and pick the first entry in the value迭代 dict 值并选择值中的第一个条目
d = {'Ernst & Young Nederland LLP': ['Mar 5 06:49:10 2021 GMT', '2048']}
for v in d.values(): print(v[0])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.