标签:整数 字符串 十六进制 进制 als com dict ring 2.3
类型转换:
int() 转换为整数integer
float() 转换为浮点数float
long(‘23‘) 转换为长整数long integer
str(2.3) 转换为字符串string
complex(3, 9) 返回复数3 + 9i
ord("A") “A”字符对应的数值
chr(65) 数值65对应的字符
unichr(65) 数值65对应的unicode字符
bool(0) 转换为相应的真假值。在python中,0相当于False
bin(56) 返回一个字符串,表示56的二进制数
hex(56) 返回一个字符串,表示56的十六进制数
oct(56) 返回一个字符串,表示56的八进制数
list((1, 2, 3, 4)) 转换为表list
tuple([1, 2, 3, 4]) 转换为定值表tuple
slice(5, 2, -1) 构建下标对象slice
dict(a=1,b="hello",c=[1, 2, 3]) 构建字典dictionary
标签:整数 字符串 十六进制 进制 als com dict ring 2.3
原文地址:https://www.cnblogs.com/thoughtful-actors/p/9035493.html