Python语法-第1关

数据类型

四则运算

type(需要查询的数据)

who = '我的'
action = '是'
destination = '镜像世界'
number = 153
code = '通行密码'

type(who)
type(action)
type(destination)
type(number)
type(code)

输出

print(type(who))
print(type(action))
print(type(destination))
print(type(number))
print(type(code))

数据转换

#将其他数据类型转换成字符串

str()函数 

#将其他数据类型转换成整型

#文字类和小数类的字符串,无法转化成整数。

#浮点数转化成整数,抹零取整。

int()

#将其他数据类型转换成浮点数

float()

总结

猜你喜欢

转载自www.cnblogs.com/AlterMe/p/11078305.html