我有这两个列表:
values = ['0.7%', '11.1%', '8.7%']
key = ['NA']
我想将其压缩为dict的(即键和值)。这样输出将如下所示:
{'NA': '0.7%', '11.1%', '8.7%'}
这是我当前的代码:
values = ['0.7%', '11.1%', '8.7%']
key = ['NA']
joiner = dict(zip(key, values))
print(joiner)
当前输出:
{'NA': '0.7%'}
答案 0 :(得分:1)
已完成:
values = ['0.7%', '11.1%', '8.7%']
key = ['NA']
joiner = {f"{key[0]}": values}
print(joiner)
答案 1 :(得分:1)
print({key[0]:' ,'.join(values)})