3 回答
![?](http://img1.sycdn.imooc.com/533e4c2300012ab002200220-100-100.jpg)
TA贡献1877条经验 获得超6个赞
print
print "Hello, World!"
print("Hello, World!")
“SyntaxError:调用‘print’时缺少括号”
>>> print("Hello, World!")Hello, World!
>>> print "Hello, World!" File "<stdin>", line 1 print "Hello, World!" ^SyntaxError: invalid syntax
print
>>> import sys>>> print >> sys.stderr, 1, 2, 3,; print >> sys.stderr, 4, 5, 61 2 3 4 5 6
>>> import sys>>> print(1, 2, 3, file=sys.stderr, end=" "); print(4, 5, 6, file=sys.stderr)1 2 3 4 5 6
>>> print "Hello!" File "<stdin>", line 1 print "Hello!" ^SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello!")?
TypeError
>>> print >> sys.stderrTraceback (most recent call last): File "<stdin>", line 1, in <module>TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'. Did you mean "print(<message>, file=<output_stream>)"?
<message>
<output_stream>
![?](http://img1.sycdn.imooc.com/545847aa0001063202200220-100-100.jpg)
TA贡献1828条经验 获得超13个赞
print "Hello, World!"
print("Hello, World!")
![?](http://img1.sycdn.imooc.com/545862120001766302200220-100-100.jpg)
TA贡献1840条经验 获得超5个赞
from __future__ import print_function # If code has to work in Python 2 and 3!
print("python")
for number in range(0, 10): print(number, end=', ')
添加回答
举报