Python字符串转字典值报错ValueError: dictionary update sequence element #0 has length 1; 2 is required

刚开始学习Python,认为字符串和字典之间转换直接用dict()就能搞定,结果程序运行起来之后报错:ValueError: dictionary update sequence element #0 has length 1; 2 is required

后来查找资料,这个数据之间不能直接转换。需要用到函数eval()转换。

Python字符串转字典值报错ValueError: dictionary update sequence element #0 has length 1; 2 is required_第1张图片

 

转换之后代码运行

Python字符串转字典值报错ValueError: dictionary update sequence element #0 has length 1; 2 is required_第2张图片

你可能感兴趣的:(python,python)