int(obj) 转换成整型
>>> 10 + 1
11
>>> 10 + int("30")
40
>>> 10 + int("1101")
1111
>>> 10 + int("1101", 2)
23
>>> 10 + int("1101", 8)
587
>>> int("1101", 16)
4353
>>>
float(obj) 转化成浮点型
>>> float("3.1") * 10
31.0
bin(obj) 转换成2进制
>>> bin(15)
'0b1111'
hex(obj) 转换成16进制
>>> hex(11)
'0xb'
oct(obj)转化成8进制
>>> oct(10)
'0o12'
>>> import math
.floor(obj) 总是取小的
>>> math.floor(22/7)
3
>>> math.floor(3.99)
3
>>> math.floor(-3.14)
-4
.trunc(obj) 总是趋向于0
>>> import math
>>> math.trunc(3.14)
3
>>> math.trunc(3.99)
3
>>> math.trunc(-3.14)
-3
.ceil(obj) 总是趋向于大
>>> math.ceil(3.14)
4
>>> math.ceil(-3.14)
-3
.pi圆周率
>>> math.pi
3.141592653589793
round(obj) 四舍五入
>>> round(3.14)
3
>>> round(3.58)
4
>>> round(3.5)
4
pow(a,b) a的b次方
>>> pow(2,3)
8
sqrt(obj) 开平方
>>> math.sqrt(12)
3.4641016151377544
>>> math.floor(math.sqrt(12))
3
decimal
>>> 0.1 + 0.1 + 0.1 - 0.3
5.551115123125783e-17
>>> import decimal
>>> x = decimal.Decimal('0.1')
>>> y = decimal.Decimal('0.3')
>>> x + x + x - y
Decimal('0.0')
>>> from decimal import Decimal
>>>