The print statement can output the specified text to the screen. For example, the output of ' Hello, world ', implemented in code as follows:
>>> print ' Hello, world '
Attention:
1. When we write code in a python interactive environment, >>>
It is a prompt for the Python interpreter, not part of the code.
2. When we write code in a text editor, never add >>> yourself.
The print statement can also be followed by multiple strings, separated by a comma "," that can be connected to a string of outputs:
>>> print ' The quick brown fox ', ' Jumps over ', ' The lazy dog ' The quick brown fox jumps over the the lazy dog
Print prints each string sequentially, encounters a comma "," and outputs a space, so the output string is spelled like this:
Print also prints integers, or calculates the result:
>>> print 300300 #运行结果 >>> print + 200300 #运行结果
Therefore, we can print the results of the calculation 100 + 200 more beautifully:
>>> print ' + + = ', + 200100 + +- #运行结果
Note: For the + 200,python interpreter automatically calculates the result 300, but, ' 100 + 200 = ' is a string rather than a mathematical formula, Python treats it as a string, please explain the above printing results yourself.
Python's print statement