问题描述
我使用的是 Python 3.3,我只输入了这 3 行:
导入sklearn为sk将 numpy 导入为 np导入 matplotlib.pyplot 作为 plt
我收到此错误:
SyntaxError: 编译单个语句时发现多个语句
我可能做错了什么?
如果有人遇到这个问题,我找到的解决方案是下载 Idlex 并使用它的 IDLE 版本,它允许多行.
在shell中,一次不能执行多个语句:
>>>x = 5y = 6SyntaxError:编译单个语句时发现多个语句你需要一一执行:
>>>x = 5>>>y = 6>>>当您看到多个语句被声明时,这意味着您看到的是一个脚本,该脚本将在稍后执行.但是在交互式解释器中,您一次只能做一个语句.
I'm in Python 3.3 and I'm only entering these 3 lines:
import sklearn as sk
import numpy as np
import matplotlib.pyplot as plt
I'm getting this error:
SyntaxError: multiple statements found while compiling a single statement
What could I be doing wrong?
Edit: If anyone comes across this question, the solution I found was to download Idlex and use its IDLE version, which allows multiple lines.
Screenshot: http://imgur.com/AJSrhhD
In the shell, you can't execute more than one statement at a time:
>>> x = 5
y = 6
SyntaxError: multiple statements found while compiling a single statement
You need to execute them one by one:
>>> x = 5
>>> y = 6
>>>
When you see multiple statements are being declared, that means you're seeing a script, which will be executed later. But in the interactive interpreter, you can't do more than one statement at a time.
这篇关于SyntaxError:编译单个语句时发现多个语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!