取绝对值
a = abs(-95)
print(a)

值有一个为假,就全为假
a = all([True,True,False])
print(a)

有一个为真,就全为真
a = any([False,True,True])
print(a)

返回一个可打印的对象字符串方式表示
a = ascii('0x\10000')
b = ascii('b\x19')
print(a,b)

将整数转换成二进制字符串
a= bin(95)
print(a)

将以个数据转换成8进制
a = oct(95)
print(a)

将一个数据转成十进制
a = int(95)
print(a)

将整数转换成十六进制字符串
a = hex(95)
print(type(a))

转为布尔类型
a = bool("")
print(a)

转换成字节形式bytes
a = bytes("吴永聪",encoding='utf-8')
print(a)

chr返回一个字符串,其ascii码是一个整形,比如chr(97)返回字符串穿"a",桉树i的范围在0-255之间。
a = chr(88)
print(a)

ord参数是一个ascii字符,返回值是一个对应的十进制整数
a = ord("X")
print(a)

创建数据字典
ret = dict({"wyc":2,"two":3})
dict(zip(("one","two"),(2,3)))
dict(one=2,two=1)
print(ret)

dir列出某个类型的所有可用方法
a = dir(list)
print(a)

help查看帮助文档
ret = help(list)
print(ret)

分别取商和余数
a = divmod(9,5)
print(a)

计算表达式的值

a = eval('1+2*5')
print(a)

exec用来执行存储在字符串或文件中的python语句
ret = exec(print("Hi,girl."))
print(ret)

filter 过滤
li = [1,2,3,4,5,6,7]
a = filter(lambda x:x>3,li)
print(a)

float浮点型
a = float(1)
print(a)

判断对象是不是属于int实列,返回True和False
a = 5
b = isinstance(a,int)
print(b)

globals 返回全局变量
locals 返回当前局部变量
name = "wyc"
def h1():

a = 1
print(locals())

h1()
print(globals())

map遍历序列,对序列中每个元素进行操作,最终获取新的序列
li = [11,22,33]
def func1(arg):

return arg + 1

new_list = map(func1,li)
for i in new_list:print(i)

max 返回集合中的最大值 max
min 返回集合中的最小值 min
a = [1,2,3,4,5,6,7]
s = max(a)
n = min(a)
print(s,n)

pow 返回x的y次幂
a = pow(2,10)
print(a)
t = pow(2,10,100)
print(t)

round 四舍五入
a = round(9.5)
print(a)

sorted 队集合排序
char = ["吴","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求和的内容
a = sum([1,2,3,4,5])
print(a)
a = sum(range(6))
print(a)

__import__通过字符串的形式,导入模块
comm = input("Please:")
ccas = __import__(comm)
ccas.f1()

需要做拼接时后加 fromlist=True

m = __import__("lib."+comm,fromlist=True)
print(m)</pre>

03-05 23:53