【发布时间】:2014-03-27 03:22:10
【问题描述】:
我有一个简单的 python 脚本,其目标是在输入特定名称时打印额外的一行。这在 3.3.4 中有效,但是当我尝试在 2.7.6 中运行它时,额外的行不是输入名称时打印。我猜我在两个 python 版本之间的更改日志中查看了一些内容。非常感谢您的帮助。
while True:
name =raw_input('Piggy: What is your name?\n').strip()
if len(name.split()) == 1:
name = name.title()
break
else:
print("Ahhhj Make it shorter or actually enter a name. If you have a name like 'Mary Joe', please separate it by using a '-'")
if name ==('dawson'):
print('Hey Developer.')
【问题讨论】:
-
raw_input不在 Py 3.x 中,所以它不会起作用。 -
@thefourtheye 我在 python 2.7.6 中写这个,我不得不降级。
标签: python string python-2.7 methods python-3.3