在Python3中接受用户输入

在Python3中接受用户输入,python,python-3.x,python-2.7,Python,Python 3.x,Python 2.7,我尝试在python 3程序中接受用户输入: name = input("Enter Employee Name: ") salary = input("Enter salary: ") company = input("Enter Company name: ") print("Printing Employee Details") print ("Name", "Salary", "Company") print (name, salary, company) 但当我运行该程序时,

我尝试在python 3程序中接受用户输入:

name    = input("Enter Employee Name: ")
salary  = input("Enter salary: ")
company = input("Enter Company name: ")
print("Printing Employee Details")
print ("Name", "Salary", "Company")
print (name, salary, company)
但当我运行该程序时,会出现以下错误:

Enter Employee Name: Tim
Traceback (most recent call last):
  File ".\aws_ec2_termiante_instances.py", line 1, in <module>
    name    = input("Enter Employee Name: ")
  File "<string>", line 1, in <module>
NameError: name 'Tim' is not defined

我做错了什么?

您的代码没有问题

这是我的输出

Enter Employee Name: Tim
Enter salary: 100
Enter Company name: google
Printing Employee Details
Name Salary Company
Tim 100 google
确保您使用的是正确的python3解释器

你可以在这里安装一个。
代码中没有任何错误。只是您正在使用Python2.x。 您必须切换到Python3.x。我的建议是更新您自己,并安装python 3.7

我有一个视频,您可以在其中学习如何在vscode中安装python 3.7。在vscode中安装python只需不到3分钟。看这个视频


你确定你使用的是Python 3环境吗?Python3上不可重新生成:你使用的是Python2-你需要使用raw_inputblablubb来获取字符串-input将尝试评估你的输入,因此名为errorUse raw_input而不是input-我猜你使用的是Python2环境可在Python2上复制: