Print Statement Learning
The print statement after Python 3 needs parentheses, without error:
1. Print the string:
A single quotation mark or double quotation mark is required to refer to the string, either single or double quotation marks, but to appear in pairs, and the parentheses to appear in pairs, otherwise the statement cannot be terminated:
>>> print ("I love Python")
>>> print (' I love Python ')
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/88/51/wKioL1fvRCyzb8DrAACrJD2Zdoc676.png-wh_500x0-wm_3 -wmp_4-s_1807197863.png "title=" Print.png "alt=" Wkiol1fvrcyzb8draacrjd2zdoc676.png-wh_50 "/>
2, calculate the value:
>>> print (3+5) # # # numerical calculation
8
>>> 3+5 # # # can also be written, directly even if the results
8
>>> print (4*6) # # # Here is the calculation of integers
24
>>> print ("4*6") # # # Here is a string, because double quotes are added
4*6
3. Add the string:
>>> print ("I love Python" + "does you?")
I Love Pythondo?
>>> print ("I love Python" + "does you?") # # Show a space between two words
I Love Python does you?
>>> print ("I love python," + "does you?") # # Add a comma and a space between two words
I Love Python, does you?
4, string and numeric multiplication:
>>> print ("I Love Python" * 3)
I love python i love python i love python
>>> print ("I Love python\n" * 3)
I Love Python
I Love Python
I Love Python
Tip: (1) using the ALT+P key will return the last command statement executed, Alt+n will display the next command statement, that is, return to the command executed by the first command!
(2) \ n = carriage return for line break
This article is from the "Davidlee's Linux Road" blog, so be sure to keep this source http://davidlinux.blog.51cto.com/5965954/1858276
Python Basic Learning Notes (i)