【发布时间】:2020-06-24 04:30:12
【问题描述】:
我需要离开这个输出
3 ['and', 'may']
5 ['short']
6 ['coffee', 'monday', 'strong']
到这个输出
3 and may
5 short
6 coffee monday strong
这是我目前的代码:
dictionary = {6:['monday', 'coffee', 'strong'], 5:['short'], 3:['may', 'and']}
def print_keys_values_inorder(dictionary):
for key in sorted(dictionary):
print(key , sorted(dictionary[key]))
print_keys_values_inorder(dictionary)
如何将列表类型的字典值转换为字符串类型?
【问题讨论】:
标签: python-3.x string list dictionary type-conversion