我如何用键将列表隐藏到字典? (python 3.7)[关闭]

问题描述 投票:-2回答:1

输入

listA = ['first', 1,2,3] 

期望的输出

dic = {'first':[1,2,3]}

这是怎么做的?

python list dictionary
1个回答
0
投票

您可以按照以下代码进行操作:

dic = {listA[0]:listA[1:]}
© www.soinside.com 2019 - 2024. All rights reserved.