How to find length of dictionary values

后端 未结 6 1696
忘了有多久
忘了有多久 2020-12-13 18:24

I am pretty new to all of this so this might be a noobie question.. but I am looking to find length of dictionary values... but I do not know how this can be done.

S

6条回答
  •  轮回少年
    2020-12-13 18:50

    To find all of the lengths of the values in a dictionary you can do this:

    lengths = [len(v) for v in d.values()]
    

提交回复
热议问题