我遇到以下错误。我无法弄清楚clonedRadardetails
中出了什么问题。任何指导都会有所帮助。
import ast
clonedRadardetails = {'clonedRadar': u'42719619', 'clonedStatus': 'PASS', 'clonedRadarFinalStatus': 'PASS', 'updatedFailedReason': 'N/A', 'clonedRadarFinalStatusReason': 'N/A', 'updateStatus': 'PASS', 'clonedStatusfailReason': 'N/A'}
v = ast.literal_eval(clonedRadardetails)
错误:
File "astliteral.py", line 3, in <module>
v = ast.literal_eval(clonedRadardetails)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 80, in literal_eval
return _convert(node_or_string)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string
答案 0 :(得分:-2)
摘自ast.literal_eval()的文档:
安全地评估表达式节点或包含Python表达式的字符串。提供的字符串或节点只能由以下Python文字结构组成:字符串,数字,元组,列表,字典,布尔值和None