Sou*_*abh 1 python eval python-2.7
我正在尝试使用python eval解析和评估公式并进行编译。在一种情况下,它正在工作,在其他情况下,它没有工作。见下文:这工作正常
>>> formula = '(00*3600)+(03*60)+10'
>>> eval(compile(formula, '<string>', 'eval'))
190
Run Code Online (Sandbox Code Playgroud)
但这给出了错误
>>> formula = '(00*3600)+(08*60)+53'
>>> eval(compile(formula, '<string>', 'eval'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
(00*3600)+(08*60)+53
^
SyntaxError: invalid token
Run Code Online (Sandbox Code Playgroud)
请帮忙。我听不懂 我正在使用Python 2.7.5