【发布时间】:2017-08-31 17:26:43
【问题描述】:
我的代码在 Win 机器、python 3.6 上运行,然后我在 mac - 终端上尝试代码并显示错误。还安装了最新版本的python 我的代码:
print ("==================================")
print (" Print all String Character ")
print ("==================================")
word_secund = input("Please add your word: ")
word_one = str(word_secund)
def list(text):
word = 0
for word in text:
print(word)
print (list(word_one))
错误信息:
Please add your word: Slavo
Traceback (most recent call last):
File "strings.py", line 5, in <module>
word_secund = input("Please add your word: ")
File "<string>", line 1, in <module>
NameError: name 'Slavo' is not defined
【问题讨论】:
-
尝试
raw_input而不是input我怀疑虽然你已经在你的Mac上安装了最新版本的python,但你的机器上安装了两个版本的python,它是python 2+默认。 -
我认为你是对的,我有冲突