Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python图书搜索算法_Python_Search - Fatal编程技术网

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)

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)              # 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 ?!