Python, how to print dictionary key and its values in each line?

前端 未结 4 1532
逝去的感伤
逝去的感伤 2021-01-29 14:23

Please see the below image for reference:

4条回答
  •  醉梦人生
    2021-01-29 14:59

    >>> for key in d:
    ...     for item in d[key]:
    ...         print key, ':', item
    1 : 2
    1 : 3
    2 : 4
    2 : 5
    

提交回复
热议问题