即使从终端运行代码,我也无法在Visual Studios中获得用户输入。
我已将设置更改为“ true”,如以下行所建议:
"code-runner.runInTerminal": true
我什至使用命令行调用来运行程序
python test_input.py
它在终端中运行程序,但是当它获取用户数据时,它说该数据是未定义的。
例如,我的代码说:
user_fav = input("What's your favorite country?")
但是当用户键入“土耳其”时,结果如下:
What's your favorite country?Turkey
Traceback (most recent call last):
File "/Users/rahme/Documents/VS_PYTHON/test_input.py", line 1, in <module>
user_fav = input("What's your favorite country?")
File "<string>", line 1, in <module>
NameError: name 'Turkey' is not defined
该如何解决?另外,每次我运行程序时都说未安装python linter。它变得很烦人,所以我禁用了它。这可能是问题吗?