# Print Print (value,..., sep= ", end= ' \ n ', File=sys.stdout,flush=false)# 1.print: You must use parentheses # 2.print: Default line break# 0. Line break issues# 3.x Version: print (x,end = "Print ("[Demo] Johnny Zen", end= ", sep= ' * ');p rint (" [Demo] Zen Johnny ", End= ' (@[email protected]) '); # [Demo 00] Johnny Zen[demo] Zen Johnny (@[email protected])# 1. Output character (string) and numeric typePrint ("[Demo] Hello World", 3120150905429, ' hello ' + "I am very happy."); # [Demo 01]hello world. 3120150905429 Hello I am very happy.# 2. Array/List []: List elements can be modified, subscript specified as integersPrint ("[Demo]", [N, ' true ', false, ' good ', ' Johnny ']); # [Demo] [[] ' true ', false, ' good ', ' Johnny ']# 3. Meta-group (): Tuples are similar to lists, except that elements of tuples cannot be modified. Print ("[Demo]", (' Google ', ' Runoob ', 1997, $)); # [Demo] (' Google ', ' Runoob ', 1997, 2000)# 4. dictionary : {key:value,key:value,...}: The dictionary is another mutable container model and can store any type of object. # Print ("[Demo]", {name: "Johnny", Age:22,sex: "Male"}) # Error: Malformed, key must be quoted print ("[Demo]", {"name": "Johnny", "Age ": +," sex ":" Male "}); # [Demo] {' name ': ' Johnny ', ' Age ': ', ' sex ': ' Male '};# 5. Formatted output: printf:[% character similar to C: start of token conversion specifier]s = "Johnny"; num = 3.14159265354;print ("[Demo] [%s,%d,%i,%-10.3f]"% (S,len (s), Len (s), num)); #%-10.3f: "10" bit width 10 bits, "-" Left-aligned, [. 3f] Precision 3-bit floating-point number # [Demo] [johnny,6,6,3.142]# # (1). % character: The start of the token conversion specifier # (2). Conversion flag:-Indicates left alignment, + denotes a positive sign before the value is converted, and "" (white space character) retains a space before the negative number, and 0 indicates that the conversion value is filled with 0 # (3) If there are not enough digits. Minimum segment width: The converted string should have at least the width specified by the value. If it is *, the width is read from the value tuple. # (4). Point (.) Heel Precision Value: If the conversion is real, the precision value represents the number of digits after the decimal point. If the string is converted, the number represents the maximum field width. If it is *, then the precision will be read from the tuple # (5). String formatting conversion type # conversion type meaning # d,i signed decimal integer # o unsigned octal # u unsigned decimal # x unsigned hexadecimal (lowercase) # x unsigned hexadecimal (uppercase) # E floating point represented by scientific notation Number (lowercase) # e scientific notation for floating-point numbers (uppercase) # f,f decimal Floating-point number # G if the exponent is greater than 4 or less than the precision value is the same as E, the other case is the same as F # G if the exponent is greater than 4 or less than the precision value is the same as E, other cases and f the same # C single-character (accept integer or single character string) # R string (using REPR conversion Any Python object) # s string (convert any Python object using str)
Python's Print Usage summary