One, the number
1,int converts a string into a number
A = ' 123 '
B=int (a)
B=123
2, convert in binary mode
Num= "a"
>>> num = "a"
>>> Int (num,base=16)
10
The default base of 10 does not need to be added
3,bit_length is currently the number of bits numbers
>>> age = 3
>>> Age.bit_length ()
2
>>> Age = 8
>>> Age.bit_length ()
4
PS: In Python3, no matter how many numbers are int type
Two, string
1,capitalize First Letter Capital
>>> test= "Zhangsan"
>>> test.capitalize ()
' Zhangsan '
2,casefold,lower the capitalization into lowercase casefold Many unknown correspondence also apply
>>> test= "Zhangsan"
>>> Test.casefold ()
' Zhangsan '
3,center minimum number of characters, not enough characters to use spaces instead, or you can use other symbols instead of spaces
>>> Test.center (8)
' Zhangsan '
>>> Test.center (9)
' Zhangsan '
>>> Test.center (10)
' Zhangsan '
>>> Test.center (11)
' Zhangsan '
>>> Test.center (10, ' * ')
' *zhangsan* '
4,count computes the number of occurrences of a subsequence in a string, and can be represented by a number representing the beginning of the search
>>> test.count (' Z ')
1
5,endswith judge whether the end of the door startswith
>>> test.endswith (' a ')
False
>>> test.endswith (' N ')
True
6,find from the beginning, find the location number (starting at 0)
>>> test.find (' H ')
1
>>> test.find (' A ')
2
7,format string is formatted to replace the placeholder in the string with the specified value
>>> test = ' I am {name} '
>>> Test.format (name= ' Zhangsan ')
' I am zhangsan '
>>> test = ' I am {0},age={1} '
>>> Test.format (' Zhangsan ', 19)
' I am zhangsan,age=19 '
8,format_map format in dictionary mode
>>> Test
' I am {name} '
>>> Test.format_map ({"Name": "Zhangshan"})
' I am Zhangshan '
9.index function similar to find if it is different from find if no direct error is found
10,isalnum determine if a string contains only letters and numbers
>>> ' ASD '. Isalnum ()
True
>>> ' asd_+ '. Isalnum ()
False
Three, List
Four, Yuan zu
Five, dictionary
VI, Boolean value
Python full stack day10 (base data type)