【发布时间】:2015-01-18 11:46:06
【问题描述】:
我是python的新手
我用python写了一段代码..
#!/usr/bin/python
s = raw_input('--> ')
print eval('s+1')
我遇到这样的错误
[root@python ~]# python 2.py
--> 2
Traceback (most recent call last):
File "2.py", line 3, in <module>
print eval('s+1')
File "<string>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
可能是什么原因..
【问题讨论】:
-
不要使用
eval:Eval really is dangerous。