有人能确认为什么在Python2.6中返回以下错误吗?这是3.0语法吗?

2024-05-15 22:29:21 发布

您现在位置:Python中文网/ 问答频道 /正文

# Get the user's first name.
first_name = input('Enter your first name: ')

# Get the user's last name.
last_name = input('Enter your last name: ')

# Print a greeting to the user.
print('Hello', first_name, last_name)

Tags: thetonamehelloinputyourgetgreeting
2条回答

使用raw_inputprint语句:

# Get the user's first name.
first_name = raw_input('Enter your first name: ')

# Get the user's last name.
last_name = raw_input('Enter your last name: ')

# Print a greeting to the user.
print 'Hello', first_name, last_name

python3将旧的raw_input函数重命名为input;在python2中,input()的意思与eval(raw_input())相同,它将尝试将给定的输入解释为Python表达式。你知道吗

您可能希望安装python3,或者考虑切换教程。你知道吗

改用raw_input。。。input尝试计算python2.x中得到的任何结果

相关问题 更多 >