Format string - method

b integer represented as a binary number

c interpreted as integer Unicode code point

d to be decimal integer processing, which is the default integer specifier

e Use scientific notation to represent the fractional (represented by index e)

E E and the same, but the index represented by E

f will be represented as a fixed-point decimal

F F is the same, but the special value (NaN3 and INF), uppercase represents

g automatic choice between fixed-point notation and scientific notation. This is the default for decimal specifier, but at least one fractional default

G and g are the same, but the use of capital and special value to represent the exponent

n and g are the same, but with the insertion region-specific number separators

o The integer octal

s remains unchanged string format, which is the default for the string specifier

x represents an integer hexadecimal number X and lowercase letters with the same x, but using uppercase

% The number of values ​​expressed as a percentage (multiplied by 100, according to f format specifier, and then followed by the%)

method

Repeatedly output string 1 *
Print ( 'HELO' *. 4)
2 [], [:] character string acquired by the index, and here is the list of slicing the same, the specific content of the list of
print ( 'hello word '[2:])
. 3 in member operator - if the specified character string contains returns True
Print (' EL 'in' Hello ')
. 4 format string
print ('% s is a super hero '%' lron man ')
5 + string concatenation
A, B, C =' One ',' TWO ',' Three '
Print (A + B + C) # inefficient
d =' '.join ([a , b, c])
print (d)

= ST. 1 'Hello Kitty Age {name} {IS}'
2 -print (st.count ( 'L')) # counting the number of elements
3 print (st.capitalize ()) # capitalized
4 -print (st .center (50, '-') ) # center
5 print (st.casefold ()) # all lowercase
. 6 Print (st.encode ())
. 7 Print (st.endswith ( 'Y')) # determines whether a content end
8 -print (st.startswith ( 'h' )) # begins with determining whether certain content
(st.expandtabs (tabsize = 10)) # define 9 print \ t interval
10 print (st.find ( 'o ')) # to find a first index and the return element not found returns -1
. 11 Print (st.rfind (' T ')) to find the last element #
12 -print (st.format (name =' max ', Age = 14))
13 is formatted output # another way
14 Print (st.format_map ({' name ':' max ',' Age ': 12 is}))
15 # formatted output
16 print (st .index ( 'o')) # find the first element can not find the error and returns the index
17 print ( 'asdasd'.Whether isalnum ()) # is detected by a string of letters and numbers
18 print ( '98'.isdecimal ()) # Check whether the string contains only decimal characters.
19 print (st.isalpha ()) # detect whether the letter string of only
20 print (st.isdigit ()) # detect whether a string consisting only of the integer
21 print (st.isidentifier ()) # for determining the character if the string is a valid identifier Python, the variable name can be used to determine the legality of
22 print (st.islower ()) # detect whether a string lowercase letters
23 print (st.isnumeric ()) # detect whether a string only the numbers.
24 print (st.isprintable ()) # determines whether the character string to be printed
25 print (st.isspace ()) # detect whether a string of blank characters only
26 print (st.istitle ()) # string detected All the words are spelled the first letter is an uppercase, lowercase letters and other
27 print (st.isupper ()) # detect whether a string of all the letters are capitalized
28 print ( ''. join ( st)) # for the elements of a sequence is connected to the specified character string to generate a new
29 print (st.ljust (50, ' -')) # returns a string of the original left-aligned and padded with spaces to the specified length new string
30 print (st.rjust (50, ' -')) # returns a string of the original right-aligned and padded with spaces to the specified length of the new string
31 -print (st.lower ()) # all modifications lowercase
32 -print (st.
33 print (st.swapcase ()) # reverse case
34 print (st.strip ()) # for line feed or a specified character string is truncated at both ends and the ends of the blank
35 print (st.lstrip ()) # newline character or specify a character string truncated left and left spaces of
36 print (st.rstrip ()) # for line breaks or cut off to the right with spaces specified character string on the right of the
37 print (st. partition ()) # for the specified delimiter string dividing
38 -print (st.replace ()) # string of old (old string) replaced with new (new string), if the specified the third parameter max, max is not more than the replacement times.
39 -print (st.split ( '') ) # string dividing the list specified in claim
40 print (st.title ()) # capitalized
# print (st.strip ()) # character is used to remove head and tail specified character string (line feed spaces or default) or character sequence
# print (st.len (st)) # Get the total number of elements

Guess you like

Origin www.cnblogs.com/nuto/p/10988252.html