Don't say a word, just cut to the chase.
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,,>>> is the prompt for the Python interpreter, not part of the code.
2. When we write code in a text editor, never add >>>
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 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 #运行结果
>>> print + #运行结果
Therefore, we can print the results of the calculation 100 + 200 more beautifully:
>>> print ' + + = ', + +
+ #运行结果
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.
at any time, we can add comments to the program. Annotations are used to illustrate the code, to yourself or others, and when the program runs, the Python interpreter ignores comments directly, so there is no comment that doesn't affect the execution of the program, but it affects whether someone can read your code. Python's comments to
#Beginning, followed by text until the end of the line is counted as comments# This line is all a comment ...
print ' Hello ' # This is also a comment
Note there is also a clever use, that is, some code we do not want to run, but do not want to delete, you can temporarily block out the comment:
want to see more detailed please see http://note.youdao.com/noteshare?id=1b9746b7432440ad7334070067d45143&sub= 6C01CC4588AE4B198025EE29DC44F5CA
Python's print statement python comment