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 ' pythontab.com ' syntaxerror:missing parentheses in call to ' print '
So python3 in print must use parentheses, because it is a function.
2. The print function in Python3 has multiple parameters, and the function prototype is as follows:
Print (value1, ..., sep= ", end= ' \ n ', File=sys.stdout, Flush=false)
From the above method prototype can be seen,
1. Print can support multiple parameters, supporting the printing of multiple strings at the same time (where ...). Represents any number of strings);
2. Sep indicates what character is used to connect between multiple strings;
3. 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.
>>> print ("Python", "tab", ". com", sep= ") pythontab.com>>> print (" Python "," tab ",". com ", sep=", End = ') #就可以实现打印出来不换行pythontab. com
The pit of input in 3.python2
Print ("What does") A = input ("Enter any Content:") print ("I-like", a)
The input string will be an error, and the problem is well solved in Python3.