假设有一个列表:['1604780184', '10', '1604780194', '0', '1604780319', '99', '1604780320', '0']
您需要得到如下结果:{'1604780184': '10', '1604780194': '0', '1604780319': '99', '1604780320': '0'}
现在我有这样的:
rline = ['1604780184', '10', '1604780194', '0', '1604780319', '99', '1604780320', '0']
total = {}
print(f"My list: {rline}")
while rline:
total[rline[0:2][0]] = rline[0:2][1]
del rline[0:2]
print(f"Dictionary: {total}")
Run Code Online (Sandbox Code Playgroud)
请告知更好的方法。谢谢。