Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
140 views
in Technique[技术] by (71.8m points)

python - Receiving NameError on input in SublimeREPL

I'm trying these lines in Python 3 using SublimeText:

a = input('Geben Sie bitte das Wort "Hallo" ein: ')
if a == "Hallo":
    print('Korrekt!')

Now if I run that in SublimeREPL I get

Geben Sie bitte das Wort "Hallo" ein: Hallo
Traceback (most recent call last):
  File "S79.py", line 1, in <module>
    a = input('Geben Sie bitte das Wort "Hallo" ein: ')
  File "<string>", line 1, in <module>
NameError: name 'Hallo' is not defined

***Repl Closed***

However, it works if I run it online.

I don't quite get it. In SublimeREPL it only works if I type

'Hallo'

instead of

Hallo

Any suggestions?

========== Update: So I did further dig into this problem, and I am starting to think that SublimeText uses Python 3 YET SublimeREPL runs my code in Python 2. For instance, raw_input produces an error in the same script if I build it but makes it work in SublimeREPL instead. Further evidence for that problem to exist I found here. Is that even possible and how can I change that?

question from:https://stackoverflow.com/questions/65876976/receiving-nameerror-on-input-in-sublimerepl

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...