# number 之间的相互转换# int <=> floatvar1 = 1;print(type(var1)) #res1 = float(var1)print(res1) #1.0print(type(res1)) # res2 = int(res1)print(res2) #1print(type(res2)) # # int or float <=> Stringvar = 1res = str(var)print(type(res)) # res = float(res)print(type(res)) # # math 使用import mathvar = math.piprint(var) #3.141592653589793...res = math.radians(180)# 将角度值转换乘弧度值3.141592653589793 即180度 对应 math.piprint(res) #3.141592653589793...res = math.degrees(math.pi) #将弧度转换成角度print(res) #180.0res = math.pow(1,2) # 等价于x 的 y 次方print(res) # 1.0print(type(res)) # res = math.ceil(2.3) # ceil 天花板取值,往上取print(res) #3res = math.floor(2.3) # floor 往下取值print(res) #2# 字符串 => 字典 也可以使用jsonvar = "{'a':20,'b':40}"print(type(var)) # res = eval(var)print(res) #{'a': 20, 'b': 40}print(type(res)) # # 字典=> 字典字符串 也可以使用jsonvar = { 'a':20,'b':40}res = str(var)print(type(res)) # print(res) #{'a': 20, 'b': 40}#字符串 => 列表 指定分割符号就行#列表 => 字符串var = [ 'a','b','c','d'] #要求列表里面都是str类型res = '-'.join(var)print(res) #a-b-c-dprint(type(res)) # # 列表 => 字典lst1 = ['k1','k2','k3']lst2 = [1,2]rest = zip(lst1,lst2) # 拉锁函数print(res)# print(type(rest)) # res = dict(rest)print(res) #{'k2': 2, 'k1': 1}print(type(res)) #