1 abs: absolute value
2 all: each element in the sequence as Boolean judgment section element is empty, none, 0 is False
3 any: there is an element in the sequence is true, for the True
4 bool: empty, none \ 0 is false, the other true
5 bytes: binary code conversion
6 decode decoding principle: coded with what, on the decoding manner corresponding to
name="你好" print(bytes(name,encoding="utf-8")) print(bytes(name,encoding="utf-8").decode("utf-8")) print(bytes(name,encoding="gbk").decode("gbk")) #ascii不能编码中文
7 chr: Find a decimal number corresponding to the position of the table in ascii, and prints the specified object
8 divmod: firm may take more than a few, commonly used in the paging function
Print (divmod (10,3)) # 10 divided by 3
9 eval: The character string extracted from the data structure
10 express: string can mathematical expressions and calculation
express="1*2+(10-6)-3/2" print(eval(express))
Hash. 11: Data types can hash the data immutable type, the same length as, the original data can not be anti-Release, commonly used in the hash check: whether the data is altered during
12 help (all), dir (all) printing explanation of the operation of the specified object
13 bin / hex / oct: decimal to binary, octal and hexadecimal conversion
print (bin (10)) # 10 hex -> binary 0b1010 ###
Print (hex (10)) hex # 10 -> 16 hexadecimal 0xA ###
Print (OCT (10)) into # 10 system -> octal ### 0o12
14 golbals print globals, locals Print this level variables
15 zip fastener Method: the sequence of processes to be iterative data types: lists, tuples and strings
# Positions from front to back, if there is no corresponding value is not output Print (List (ZIP (( " A " , " B " , " C " ), (l, 2,3)))) # ### [( ' a ', 1), (' b ', 2), (' c ', 3)]
p={"name":"alex","age":18,"gender":"none"} print(list(zip(p.keys(),p.values()))) ####[('name', 'alex'), ('age', 18), ('gender', 'none')]
print(list(zip(["a","b"],"124546")))####[('a', '1'), ('b', '2')]
16 max&min
1) Comparison of different data types can not be
2) when compared between each element is compared in turn from the first position of each element if the first element size was separated, behind the need to continue the comparison, corresponding to this element directly obtained value
ll=["a11","b12","c11"] print(list(max(ll)))
li=[(5,"a"),(1,"b"),(3,"u"),(4,"d")] print(list(max(li)))####[5, 'a']
# Value and maximum age value Age LL = { " AGE1 " : 10, " Age2 " : 50, " Age3 " : 33 is, " age4 " : 20 is } Print (max (ZIP (ll.values (), ll.keys ()))) # (50, 'Age2')
3) complex usage
# Max (people) shows the comparison of each dictionary, because the dictionary is not iteration object, it will be an error. Therefore, each element in the dictionary should be taken out, removed the age and age corresponding key values Print (max (people, key = the lambda DIC: DIC [ " age " ])) # for loop corresponding to # RET = [] # for i in people: # ret.append (i [ "Age"]) # Print (RET)
A power of 17 pow
print(pow(3,4,2)) #3**4%2
18 reversed inverted data
l=[1,3,5,2] print(list(reversed(l))) [2, 5, 3, 1]
19 round rounding
20 slice sliced
= L " Hello " S1 = Slice (1,5,2) # . 1 as a starting position. 5 as the end position is not included, step 2 Print (L [S1]) The results: el
21 sorted sort: the same data type
method one: people=[ {"name":"alex","age":1000}, {"name":"CC","age":10000}, {"name":"nana","age":999}, {"name":"XX","age":18}, ] print(sorted(people,key=lambda dic:dic["age"])) Second way: name_dic={ "nana":999, "cc":123, "KK":333 } print(sorted(zip(name_dic.values(),name_dic.keys())))
Analyzing the data type 22 type: determining if done according to different types of data
msg="123" if type(msg) is str: msg=int(msg) res=msg+1 print(res)