【发布时间】:2013-10-14 20:02:13
【问题描述】:
print('10 -> 2 [bd], 2 -> 10 [db]')
answ=input('select db or bd : ')
if answ == "db":
a=input('enter a digit')
x=int(a)
list1 = []
while (x):
x%2
x//2
if x==0:
break
我开始在 python 3.2 上创建它,但后来我不得不继续使用 python 2.7.5,我收到以下错误消息:
Traceback (most recent call last):
File "C:\Users\<file path>", line 3, in <module>
answ=input('select db or bd : ')
File "<string>", line 1, in <module>
NameError: name 'db' is not defined
>>>
我真的不知道帽子是怎么回事,在 python 3.2 上工作得很好(对不起我的英语不好)。
【问题讨论】:
-
用 raw_inputs 替换输入,并在等号之间添加空格,工作。感谢您的支持:)
标签: python string list if-statement compiler-errors