python 各种数据类型转换

转换为整形int
num = int(“123”) 123
num2 = int(123.45) 123
浮点型float:
字符串转浮点型 num3 = float(“123.45”) 123.45
函数math.floor()
函数round()
函数math.modf

字符串型str:
str1 = str(123) “123”

猜你喜欢

转载自blog.csdn.net/free__o/article/details/88551662