问题
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
回答1:
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.
回答2:
yes, you can only do that BUT if you want to do more than once then you need to use a notepad type in your code and then save it as (your file name) and .py this says it is a python file, hope that helps!
(P.S i'm actually 10 years old doing an online MIT course the link for the course is here: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00-introduction-to-computer-science-and-programming-fall-2008/)
来源:https://stackoverflow.com/questions/21226808/syntaxerror-multiple-statements-found-while-compiling-a-single-statement