简体   繁体   中英

Why is Python 3.1.3 in the header listed as a syntax error?

I'm a newbie programmer so I'll do my best to clearly ask my question. I'm running Python scripts in Mac 10.6.5 and now trying to write and save to a text file (following instructions in HeadsUp Python book). Whenever I hit function+F5 (as instructed) I get the same "invalid syntax" error and Idle highlights the "1" in "Python 3.1.3" of the header. Here's the header to which I'm referring:

Python 3.1.3 (r313:86882M, Nov 30 2010, 09:55:56) [GCC 4.0.1 (Apple Inc. build 5494)] on darwin Type "copyright", "credits" or "license()" for more information.

Extremely frustrating. I've checked and rechecked the code but this doesn't seem to be code related because the "syntax error" is in regards to the header text that posts in every Idle/Python session. Help anyone?

@squashua: I have the same issue when I try to run the code either in IDLE or Ubuntu terminal. Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25)

it highlights "5" as syntax error.

... and Idle highlights the "1" in "Python 3.1.3" of the header ...

Standalone Python scripts used to contain a "header", but that would be just

#!/usr/bin/env python

or, depending on the name of the interpreter maybe

#!/usr/bin/env python3.1

Not sure I understand your question, though.

you are writing your script in the wrong IDLE window ! when starting IDLE, it opens 2 windows: one for writing a script and another one with an interactive python shell. executing the content of the interactive python shell makes no sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM