下面的代碼是不工作:簡單的Python代碼是不能工作
person = input('Enter your name: ')
print('Hello', person)
而不是打印Hello <name>
它給我下面的追溯的:
Traceback (most recent call last):
File "C:/Users/123/Desktop/123.py", line 1, in <module>
person = input('Enter your name: ')
File "<string>", line 1, in <module>
NameError: name 'd' is not defined
您使用的是什麼版本的Python?這看起來像一個Python 2錯誤,如果是這樣,你應該使用'raw_input()' – MooingRawr
你是如何運行這個?在命令行上,一個IDE等?代碼中沒有d,所以你得到這個答案很奇怪。 – bikemule
你應該添加,你輸入這個「d」 – PRMoureu