简体   繁体   English

有没有办法像 python 中的枚举列表一样查看字典?

[英]Is there a way to see dictionary like an enumerate list in python?

the question might be not clear enough of what I'm trying to figure out so here are the details.这个问题可能对我想要弄清楚的内容不够清楚,所以这里有详细信息。

For instance, if I have a list that looks something like this {'a': 1, 'b':2, 'c':3, 'd':4}例如,如果我有一个看起来像这样的列表 {'a': 1, 'b':2, 'c':3, 'd':4}

How can I see it like as below?我怎样才能看到它如下所示?

a: 1一个:1

b: 2乙:2

c: 3 c:3

d: 4 d: 4

Thanks in advance提前致谢

for k, v in d.items(): 
    print(k,':', v)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM