Python脚本NameError:在Linux CentOS上

时间:2019-02-24 23:41:45

标签: python linux

我有一个虚拟机CentOS Linux版本7.6.1810,已经安装了python2,并且具有以下python脚本:

 #!/bin/python2

 name = input('Please insert your name: ')
 age = input('Please insert your age: ')

 age = eval(age)

执行脚本时,出现以下标准输出和标准错误:

 [rogeliovs@hostname ~]$ python ./helloworld.py
 Please insert your name: rogelio
 Traceback (most recent call last):
    File "./helloworld.py", line 7, in <module>
       name = input('Please insert your name: ')
    File "<string>", line 1, in <module>
 NameError: name 'rogelio' is not defined
 [rogeliovs@hostname ~]$

为什么我会收到错误消息????

1 个答案:

答案 0 :(得分:2)

使用raw_input()代替input()