【发布时间】:2019-04-19 21:41:12
【问题描述】:
MacOS 10.11.6 上 IDLE Python 3.7.1 Shell 窗口中的以下代码片段会导致语法错误。
解决办法是什么?
在终端 Python 2.7.10 或 Python3 中运行的相同代码不会导致错误。
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> import subprocess
from time import strftime
import time
SyntaxError: multiple statements found while compiling a single statement
>>>
【问题讨论】:
-
为什么要导入
time两次?似乎这就是出现错误的原因。 -
你不能像在 IDLE 中那样执行多个语句。然而,IPython(就像在 Spyder 中一样)可以做到这一点
标签: python subprocess syntax-error python-idle