Take the absolute value
a = abs(-95)
print(a)
One of the values is false , It's all fake
a = all([True,True,False])
print(a)
One is true , It's all true
a = any([False,True,True])
print(a)
Returns a printable string representation of an object
a = ascii('0x\10000')
b = ascii('b\x19')
print(a,b)
Convert an integer to a binary string
a= bin(95)
print(a)
Convert data into 8 Base number
a = oct(95)
print(a)
Convert a data to decimal
a = int(95)
print(a)
Convert an integer to a hexadecimal string
a = hex(95)
print(type(a))
To boolean type
a = bool("")
print(a)
Convert to byte form bytes
a = bytes(" Wu yongcong ",encoding='utf-8')
print(a)
chr Returns a string , Its ascii Code is a shaping , such as chr(97) Returns the string "a", eucalyptus i The scope of 0-255 Between .
a = chr(88)
print(a)
ord The parameter is one ascii character , The return value is a corresponding decimal integer
a = ord("X")
print(a)
Create data dictionary
ret = dict({"wyc":2,"two":3})
dict(zip(("one","two"),(2,3)))
dict(one=2,two=1)
print(ret)
dir List all available methods for a type
a = dir(list)
print(a)
help View help documents
ret = help(list)
print(ret)
Take quotient and remainder respectively
a = divmod(9,5)
print(a)
a = eval('1+2*5')
print(a)
exec Used to execute... Stored in a string or file python sentence
ret = exec(print("Hi,girl."))
print(ret)
filter Filter
li = [1,2,3,4,5,6,7]
a = filter(lambda x:x>3,li)
print(a)
float floating-point
a = float(1)
print(a)
Judge whether the object belongs to int Solid column , return True and False
a = 5
b = isinstance(a,int)
print(b)
globals Return global variables
locals Returns the current local variable
name = "wyc"
def h1():
a = 1
print(locals())
h1()
print(globals())
map Ergodic sequence , Operate on each element in the sequence , Finally get the new sequence
li = [11,22,33]
def func1(arg):
return arg + 1
new_list = map(func1,li)
for i in new_list:print(i)
max Returns the maximum value in the collection max
min Returns the minimum value in the set min
a = [1,2,3,4,5,6,7]
s = max(a)
n = min(a)
print(s,n)
pow return x Of y The next power
a = pow(2,10)
print(a)
t = pow(2,10,100)
print(t)
round rounding
a = round(9.5)
print(a)
sorted Team set order
char = [" Wu ","123","1","25","a","b","c"]
new_chat = sorted(char)
print(new_chat)
for i in new_chat:
print(bytes(i,encoding='utf-8'))
sum The content of summation
a = sum([1,2,3,4,5])
print(a)
a = sum(range(6))
print(a)
__import__ In the form of strings , The import module
comm = input("Please:")
ccas = __import__(comm)
ccas.f1()
m = __import__("lib."+comm,fromlist=True)
print(m)</pre>