热线电话:13121318867

登录
2019-03-11 阅读量: 567
分区运算符“//”在python2.7和3.0中的区别

在python2.7中,“//”运算操作如下:

# "//" for both integers and floating points

print 5//2

print -5//2

print 5.0//2

print -5.0//2

输出:

2
-3
2.0
-3.0

在Python 3中,'/'运算符为int和float参数执行浮点除法。

# A Python 3 program to demonstrate use of 
# "/" for both integers and floating points
print (5/2)
print (-5/2)
print (5.0/2)
print (-5.0/2)
0.0000
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子