<分区>
我是 python 菜鸟,刚开始学习这个。我正在尝试按照这本书为初学者自动执行 python 实用编程的无聊内容,但在我的第一次练习中收到错误。本书使用的是python 3,我使用的是python 2.7.6
我试图通过放置括号或去掉括号来更改它,但无法弄清楚。请就此提供帮助。
错误:
Traceback (most recent call last):
File "first.py", line 5, in <module>
myName = input()
File "<string>", line 1, in <module>
NameError: name 'test' is not defined
编写的代码:
print "Hello world"
print "What is your name?" #ask for their name
myName = input()
print "nice to meet you, " + myName
print "the length of your name is:"
print (len(myName))
print "What is your age?" # asking for age this time
myAge = input()
print "You will be " + str(int(myage) +3) + "in three years."