python图书搜索算法
python搜索查询中出现错误:python图书搜索算法,python,search,Python,Search,python搜索查询中出现错误: return eval(raw_input(prompt))File "<string>", line 1 Bel and the Dragon ^ SyntaxError: unexpected EOF while parsing 把它分解一下 s = raw_input(prompt) # prompt user to enter a string res = eval(s)
return eval(raw_input(prompt))File "<string>", line 1 Bel and the Dragon
^
SyntaxError: unexpected EOF while parsing
把它分解一下
s = raw_input(prompt) # prompt user to enter a string
res = eval(s) # try to evaluate the string as a Python expression ?!
因此,如果用户输入4+6
,eval
将运行它并返回10
Bel和thedragon
不是Python表达式,因此尝试eval
会产生语法错误。什么是eval(原始输入(提示))
做什么?这是一个错误。您可以在使用返回eval(原始输入(提示))的地方添加代码吗
s = raw_input(prompt) # prompt user to enter a string
res = eval(s) # try to evaluate the string as a Python expression ?!