run a program in python interpreter is ok, but receive syntax error when run script
Just a very simple python program
test.py
import matplotlib.pyplot as plt plt.plot(1,2) plt.show()
Once I type $python and type the program code line by line, everything is perfect. But when I type command line: $python test.py,
it shows:
plt.plot(1,2) ^ SyntaxError: invalid syntax
Why it is like that? Thanks.
Just a very simple python program
test.py
import matplotlib.pyplot as plt plt.plot(1,2) plt.show()
Once I type $python and type the program code line by line, everything is perfect. But when I type command line: $python test.py,
it shows:
plt.plot(1,2) ^ SyntaxError: invalid syntax
Why it is like that? Thanks.
No comments:
Post a Comment