简体   繁体   中英

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}

How can I see it like as below?

a: 1

b: 2

c: 3

d: 4

Thanks in advance

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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