Print () method is available in both Python2 and Python3 for printing information, but print is slightly different between two versions
Mainly reflected in the following aspects:
Print in 1.python3 is a built-in function with multiple parameters, while print in Python2 is a grammatical structure;
2.python2 can be printed without brackets: print ' Hello World ', Python3 need bracket print ("Hello World")
In 3.python2, input requires the string to be quoted, in order to avoid reading some of the behavior of non-string types, you have to use Raw_input () instead of input ()
1. In Python3, perhaps the developer feels that print has two identities at the same time, leaving only the identity of the function:
Print (Value1, ..., sep=", end='\ n', File=sys.stdout, Flush=false)
View Code
From the above method prototype can be seen,
①. Print can support multiple parameters, which supports printing multiple strings at the same time (where ...). Represents any number of strings);
②. Sep indicates what character connections are used between multiple strings;
③. End indicates what characters are added at the end of the string, and it is easy to set the print without wrapping, and the print statement under python2.x will wrap after the output string, if you do not want to wrap, just add a "," at the end of the statement. But in Python 3.x, print () becomes a built-in function, and the old method of adding "," does not work.
1>>>Print("python","Tab",". com", sep="') 2 pythontab.com3>>>Print("python","Tab",". com", sep="', end="')#You can print it out without wrapping it.4Pythontab.com
Python2 can be printed without parentheses: print ' Hello World ', Python3 needs braces for print ("Hello World") Python3 print must use parentheses because it is a function.
Different points of print in Python2 and Python3