在 Python 2.7 中,以下两者都将执行相同的操作
print("Hello, World!") # Prints "Hello, World!"
print "Hello, World!" # Prints "Hello, World!"
但是以下不会
print("Hello,", "World!") # Prints the tuple: ("Hello,", "World!")
print "Hello,", "World!" # Prints the words "Hello, World!"
在 Python 3.x 中,括号 onprint
是强制性的,本质上使它成为一个函数,但在 2.7 中,两者都会产生不同的结果。print
在 Python 2.7 中我还应该了解什么?