globals()
locals()
iter()
next()
range()
input()
print()
id()
hash() #目的是为了存储,计算之后是一个数字,hash值尽量的不要重复,在某些特定条件下有可能会重复
import os import(“os”)
open()
help(str) #辅助文档
dir(str) # 所有方法名字
callable() 是否可以被调用执行 返回 True 和 False, 函数可被调用
bool()
int()
float()
complex() 复数
bin() binary 二进制 0b 表示二进制
oct() OCTAL 八进制 0o 表示八进制
hex() 十六进制 0x 十六进制
abs() 求绝对值
divmod(x, y) 计算商和余数x被除数 y除数
round() 四舍五入
pow(x, y, z) x的y次方 z计算余数
sum() 求和
min() 最小值
max() 最大值
list()
tuple()
reversed() 翻转,返回的是迭代器
slice() 切片
memoryview() 内存展示
chr() 输入编码表的位置, 返回字符
ord() 输入字符,找这个字符在编码表上的位置
ascii() 在不在ascii码中 不在返回uXXX
\不让引号作为字符串的开头或者结尾
repr() 正式(官方的字符串), 给程序员看的,也是存储在电脑里的
print(r"xxxx") 原样字符串
print(“我叫%r” % “周润发”) 调用的是repr()显示官方字符串
format() 格式输出
test = “aaabbbccc”
print(format(test, “^20”))
print(format(10, ‘b’))
print(bin(10))
print(oct(10))
print(hex(22))
print(format(10, ‘X’))
print(format(10))
print(format(10, ‘b’))
print(format(97, ‘c’))
print(format(0.000000123456789, ‘e’))
print(format(123456789,‘0.29e’))
print(format(1.23456789,‘f’))
print(format(1.2345678,‘0.2f’))
print(format(1.23456789, ‘0.10f’))
eval() #动态执行代码片段 把字符串还原成代码
exec() 执行
compile() 编译
s = “for i in range(10): print(i)”
c = compile(s, “”, “exec”)
exec©
s = “5+9”
c = compile(s, “”, “eval”)
ret = eval©
print(ret)
s = “content = input(‘请输入你的名字:’)”
c = compile(s, “”, “single”)
exec©
print(content)