Why am I getting a SyntaxError in the Python interpreter?
问题 This code works when I try it from a .py file, but fails in the command line interpreter and Idle. >>> try: ... fsock = open("/bla") ... except IOError: ... print "Caught" ... print "continue" File "<stdin>", line 5 print "continue" ^ SyntaxError: invalid syntax I'm using python 2.6 回答1: With Python 3, print is a function and not a statement, so you would need parentheses around the arguments, as in print("continue") , if you were using Python 3. The caret, however, is pointing to an earlier