eval的作用,是去掉字符串外面的引号。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
>>> a=input()
1
>>> a
'1'
>>> eval(a=input())
1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: eval() takes no keyword arguments
>>> eval(input())
1
1
>>> b=eval(input())
1
>>> b
1