Input
1 format:
Input ([prompt]) prompt for cue information ctrl + Z end input
2 function functions:
Accepts a standard input data, returns a string type
3 Examples:
Print
1 format:
print ([object, ...], *, sep= ', end= ' \ n ', file=sys.stdout) (end default value is carriage return, customizable symbol)
2 function functions:
Output various types of data: String, Integer, floating-point, perceive, and precision control
3 Examples:
- Print (): Output a blank line
- Print (str or number): Direct output of a string or numeric
- Parameter formatted output
- #%x---hex hex
- #%d---Dec decimal
- #%o---Oct octal
- #%s---String
- #%f---float floating point
- Example 1:
- STR1 = "The value is:"
- Number1 = 11
- Print ("%s%d"% (str1,number1)) #输出 "The value is:11"
-
-
- Example 2:
- pi=3.1415926
- Print ("PI =%10.3f"% math.pi) #输出PI = 3.142
- Print ("PI =%-10.3f"% math.pi) #输出PI = 3.142
- Example 3:
- Print ("%.3s"% ("ABCDE")) #输出abc
- Print ("%.*s"% (4, "ABCDE")) #输出abcd
- Print ("%10.3s"% ("ABCDE") #输出ABC (total length is 10, character length is not sufficient in front of the blanks)
-
-
- Example 4: Printing multiple lines
- Print ("Your Content" ") or print (" Your content ")
- Example 5: Print plain text with no escape character: print (R ' content ') or print (R ' content ')
- Print (R ' abc\n ') #直接打印字符串abc \ n
Python Learning DAY3 (function input & print)