Python basic data types and strings

Basic data type
    
    
        number int , all functions, put in int
            a1 = 123
            a1 = 456
            
            - int
                converts string to number
                    a = "123"
                    print(type(a),a)

                    b = int(a)
                    print (type(b),b)
                    
                    num = "0011"
                    v = int(num, base=16)
                    print(v)
            - bit_lenght
                    # The binary of the current number, represented by at least n bits
                    r = age.bit_length()
            
        string str
            s1 = "asdf"
            s2 = "asdffas"
            
            # test = "aLex"
            # capitalize
            # v = test.capitalize()
            # print(v)

            # All lowercase, casefold is more powerful, many unknown pairs are correspondingly lowercase
            # v1 = test.casefold()
            # print(v1)
            # v2 = test.lower( )
            # print(v2)

            # Set the width and center the content
            # 20 refers to the total length
            # * Blank unknown padding, one character, optional
            # v = test.center(20,"中")
            # print(v )

            # Go to the string to find the number of occurrences of the subsequence
            # test = "aLexalexr"
            # v = test.count('ex')
            # print(v)

            # test = "aLexalexr"
            # v = test.count(' ex',5,6)
            # print(v)

            # owe
            # encode
            # decode

            # ends
            with what # starts with what
            # test = "alex"
            # v = test.endswith('ex')
            # v = test.startswith('ex')
            # print(v)

            # owes
            # test = "12345678\t9"
            # v = test.expandtabs(6)
            # print(v,len(v))

            # Search backward from the beginning, after finding the first one, get its unknown
            # > or >=
            # test = "alexalex"
            # not found -1
            # v = test.find('ex')
            # print(v)

            # index not found, error is ignored
            # test = "alexalex"
            # v = test.index('8')
            # print(v)


            # Format, replace placeholders in a string with the specified value
            # test = 'i am {name}, age {a}'
            # print(test)
            # v = test.format( name='alex',a=19)
            # print(v)

            # test = 'i am {0}, age {1}'
            # print(test)
            # v = test.format('alex',19)
            # print (v)

            # Format, passed in values ​​{"name": 'alex', "a": 19}
            # test = 'i am {name}, age {a}'
            # v1 = test.format(name= 'df',a=10)
            # v2 = test.format_map({"name": 'alex', "a": 19})

            # Whether the string contains only letters and numbers
            # test = "123"
            # v = test.isalnum()
            # print(v)
            
        list list
            ...
        tuple
            ...
        dictionary dict
            ...
        
        boolean bool
            ...
    
    
   

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324775810&siteId=291194637