Python内置函数
- Python内置函数- __import__() 函数
- Python内置函数- zip()函数
- Python内置函数-vars()函数
- Python内置函数-type()函数
- Python内置函数-tuple 函数
- Python内置函数-super()函数
- Python内置函数-sum()函数
- Python内置函数-str()函数
- Python内置函数-staticmethod()函数
- Python内置函数-sorted()函数
- Python内置函数-slice()函数
- Python内置函数-setattr()函数
- Python内置函数-set() 函数
- Python内置函数-round()函数
- Python内置函数-reversed函数
- Python内置函数-repr()函数
- Python内置函数-range() 函数
- Python内置函数-property() 函数
- Python内置函数-print() 函数
- Python内置函数-pow() 函数
- Python内置函数-ord()函数
- Python内置函数-open()函数
- Python内置函数-oct() 函数
- Python内置函数-next() 函数
- Python内置函数-min() 函数
- Python内置函数-memoryview() 函数
- Python内置函数-max() 函数
- Python内置函数-map()函数
- Python内置函数-locals() 函数
- Python内置函数-list()函数
- Python内置函数-len()函数
- Ptyhon内置函数-iter()函数
- Python内置函数-issubclass()函数
- Python内置函数-isinstance() 函数
- Python内置函数-int() 函数
- Python内置函数-input()函数
- Python内置函数-id()函数
- Python内置函数-hex()函数
- Python内置函数-help()函数
- Python内置函数-hash() 函数
- Python内置函数-hasattr() 函数
- Python内置函数-globals() 函数
- Python内置函数-getattr() 函数
- Python内置函数-frozenset() 函数
- Python内置函数-format()函数
- Python内置函数-float()函数
- Python内置函数-filter()函数
- Python内置函数-exec()函数
- Python内置函数-eval()函数
- Python内置函数-enumerate() 函数
- Python内置函数-divmod()函数
- Python内置函数-dir()函数
- Python内置函数-dict()函数
- Python内置函数- delattr()函数
- Python内置函数-complex()函数
- Python内置函数-compile() 函数
- Python内置函数-classmethod()函数
- Python内置函数-chr() 函数
- Python内置函数-callable() 函数
- Python内置函数-bytes函数
- Python内置函数-bytearray() 函数
- Python内置函数-bool()函数
- Python内置函数-bin() 函数
- Python内置函数-ascii()函数
- Python内置函数-any() 函数
- Python内置函数-all() 函数
- Python内置函数-abs() 函数
- Python内置函数-大全
Python内置函数-int() 函数
Python3内置函数--int()
int()函数描述:
int() 函数用于将一个字符串转换为十进制整型。
int()函数语法:
class int(x, base=10)
int()函数参数:
x -- 字符串或数字,x为数字时,base只能是默认。
base -- 指定x的进制数,默认十进制。
int()函数返回值:
返回整型数据。
int()函数实例:
print(int()) # 0 不传入参数时,得到结果0 print(int('100')) # 100 没有传入参数base,默认是10进制 print(int(3.854)) # 3 浮点数求整,不四舍五入 print(int('10',16)) # 16 十六进制 print(int('10',8)) # 8 八进制 print(int('10',4)) # 4 四进制 print(int('10',2)) # 2 二进制 print(int('0xf',16)) # 15 十六进制包括0 1 2 3 4 5 6 7 8 9 a b c d e f print(int('104',16)) # 260 1*16^2 + 0*16^1 + 4*16^0 print(int('123',8)) # 83 1*8^2 + 2*8^1 + 3*8^0 print(int('122',4)) # 26 print(int('101',2)) # 5
int()作用
1,可以把2进制,4进制,8进制,16进制的字符串转化为十进制整数
2,取浮点型的整数部分,只取整数,不四舍五入。
最后修改:2020年3月21日 22:51