在Mac上使用终端作为交互式解释器

问题描述 投票:0回答:1

我正在尝试使用Mac的终端调试和测试我的python程序,但我总是收到错误消息。

有人可以帮忙吗,我需要在Mac上写一些不同的东西吗?以下是我写的内容和错误。我已经尝试了几种不同的方式,例如从和其他文件导入,但始终出现相同的错误消息。

Type "help", "copyright", "credits" or "license" for more information.
>>> python -i notebook.py
  File "<stdin>", line 1
    python -i notebook.py
              ^
SyntaxError: invalid syntax
>>> 
python
1个回答
0
投票

您需要跑步

$ python3 -i notebook.py

在终端中。 不要首先使用$ python3命令打开Python解释器。

© www.soinside.com 2019 - 2024. All rights reserved.