import math a=[1,2,3] b=[1,4,5] c=a+b print(c) #[1, 2, 3, 1, 4, 5] c.sort() print(c) [1, 1, 2, 3, 4, 5] c.sort(reverse=False) print(c) #[1, 1, 2, 3, 4, 5] c.sort(reverse=True) print(c) #[5, 4, 3, 2, 1, 1] print("---") a.extend(b) print(a) #[1, 2, 3, 1, 4, 5] print("----") c=math.floor(5/2) #2 print(type(c)) #int print(5/2) # 2.5 print(5//2) #商 2 print(6.2/2) #3.1 print(6.2//2) #3.0 print(6/2) #3.0 print(6//2) #3 # / "就表示 浮点数除法,返回浮点结果;" // "表示整数除法。 x = 3.141596257 print(round(x,3)) #只截取小数点后3位的数,3.142 y = 3.0000 print(round(y,3)) #小数点后3位都为0,所以把多余的0去掉,3.0 x = 3.141596257 print("%.5f" %x) #3.14160 print(int(5/2)) #将int(2.5)返回变成2
python的/ 和// 学习
最新推荐文章于 2024-08-23 16:53:34 发布