Print does't work in Python 3.3? -
this question has answer here:
- syntax error on print python 3 [duplicate] 10 answers
i running python in visual studio professional 2013 rc. have installed the python tools visual studio, comes python 3.3.
i doing simple print statement, reports syntax error.
print 'aaa'
also, after enter enter, interpreter refuses print aaa
out. screenshot follows:
error message interpreter:
>>> print '1 ... ' ... traceback (most recent call last): file "c:\program files\microsoft visual studio 12.0\common7\ide\extensions\microsoft\python tools visual studio\2.0\visualstudio_py_repl.py", line 627, in run_one_command self.execute_item() file "c:\program files\microsoft visual studio 12.0\common7\ide\extensions\microsoft\python tools visual studio\2.0\visualstudio_py_repl.py", line 601, in execute_code_work_item code = compile(self.current_code, '<stdin>', 'single', self.code_flags) file "<stdin>", line 1 print '1 ^ syntaxerror: eol while scanning string literal >>> a=1 >>> print traceback (most recent call last): file "c:\program files\microsoft visual studio 12.0\common7\ide\extensions\microsoft\python tools visual studio\2.0\visualstudio_py_repl.py", line 627, in run_one_command self.execute_item() file "c:\program files\microsoft visual studio 12.0\common7\ide\extensions\microsoft\python tools visual studio\2.0\visualstudio_py_repl.py", line 601, in execute_code_work_item code = compile(self.current_code, '<stdin>', 'single', self.code_flags) file "<stdin>", line 1 print ^ syntaxerror: invalid syntax >>>
i used play around python 2.7. why in 3.3?
print
no longer statement in python 3, function print()
, hence correct syntax is:
print('aaa')
Comments
Post a Comment