我收到格式錯誤的字符串錯誤。爲什麼此字符串不適用於ast.literal_eval
這裏是我的testings
>>> eval("'Hello:: '+'fdsfds'")
'Hello:: fdsfds'
>>> import ast
>>> ast.literal_eval("'Hello:: '+'fdsfds'")
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
ast.literal_eval("'Hello:: '+'fdsfds'")
File "C:\Python27\lib\ast.py", line 80, in literal_eval
return _convert(node_or_string)
File "C:\Python27\lib\ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string
我認爲ast檢查它是否可執行... –