【发布时间】:2021-01-14 23:37:34
【问题描述】:
我编写了一个简单的代码,将输入的值分配给变量并打印该变量,相同的代码在我的 windows pc 上有效,但在我的 M1 MacBook Air 上无效。这是我的问题,我可能遗漏了一些东西,还是这只是 M1 芯片的问题?我对编码相当陌生,所以也许我在 vs 代码中有一些错误的设置,任何帮助将不胜感激。 screenshot from my MacBook
python -u "/Users/jeff/Documents/whynowork.py"
jeff@Jeffs-MacBook-Air ~ % python -u
"/Users/jeff/Documents/whynowork.py"
Enter input:hello
Traceback (most recent call last):
File "/Users/jeff/Documents/whynowork.py", line 1, in <module>
example = input("Enter input:")
File "<string>", line 1, in <module>
NameError: name 'hello' is not defined
jeff@Jeffs-MacBook-Air ~ %
我收到回复说我使用的是 python 2,但在底部的 vs 代码中(即使在屏幕截图中你也可以看到)我认为我使用的是 python 3.8.2。
【问题讨论】:
-
将代码和错误作为文本复制并粘贴到您的问题中;根据minimal reproducible example 规则的要求,仅在屏幕截图中给出的内容并不“包含在问题本身中”。 (见Meta Stack Exchange问题Why not upload images of code/errors when asking a question?)
-
我 99% 确定您在 Windows PC 上运行 Python 3,在 Macbook 上运行 Python 2(这是 macOS 上的默认设置)
标签: python visual-studio-code apple-m1