我没有o图片,但我问了一个问题,因为我是使用python的初学者
答案 0 :(得分:2)
input()
将用户输入作为字符串。非常安全。
>>> usr = input('Enter some input: ')
Enter some input: hello, world
>>> usr
"hello, world"
eval()
将像执行python代码一样执行字符串。非常危险。
>>>eval(input('Make it happen!'))
Make it happen! print('hello')
hello
>>>eval(input('Make it happen!'))
Make it happen! os.system('echo malicious things')
现在您真的把计算机弄糟了。
答案 1 :(得分:1)
eval()
用于评估表达式,input()
用于接受用户输入。以下是示例:
#evaluates expression
>> eval('5+2')
>> 7
# Takes user input
>> input()
10 (user enters)
>> 10
#evaluates user input
>> eval('input()')
15 (user enters)
>> 15