Python basics-basic data types, python Data Types
Common functions of basic data types:
1. INTEGER (int)
- Bit_length (self) # obtain the shortest binary digits that can be expressed
- + ,-
X = 4
Print (x. bit_length ())
2. String (str)
- Center # center format: a1.center (20 .'*')
- Count # Number of occurrence times of the string neutron sequence: a1.count ("AB",) or a1.count ("AB ")
- Endswith # Whether to end with AB, return True or Fales format: a1.endswith ('AB',) or a1.endswith ('AB ')
- Startswith
- Expandtabs # converts the Tab key (\ t) to a space key. By default, it is converted to eight spaces.
- Find # find and return the location. -1 not found
- Rfind
- Format # convert the placeholder ({0}, {1} ·) in the string to the set value.
- Join # concatenates strings in * join format: "***". join (a1)
- Ljust # The content is left aligned and filled on the right, similar to the center format: a1.ljust (30 ,'*')
- Must UST
- Lower # Small write
- Lstrip # Remove spaces on the left
- Rstrip # Remove spaces on the right
- Strip # Remove spaces on both sides
- Partition # split, front, middle, and back. The returned result is of the tuples. Format: a1.partition ('AB ')
- Rpartiton
- Replace # replacement format: a1.replace ("AB", "cc", 1) replace the first AB from left to right with cc
- Split # format: split ('E', 1)
- Rsplit
- Swapcase # case-insensitive Conversion
- Title # title
- Upper
Index
A1 [0]
A1 [1]
Len (a1) # Length
Slice
A1 [0: 2]
Loop
While I <len (s ):
A2 = a1 [I]
Or
For I in a1:
Print (I)
3. list)
Index
Slice
For Loop
- Append # append format: list1.append ("abcd ")
- Count # statistics format: list1.count ("abcd ")
- Iterable # iteratable