python运算符一些注意项
2016-05-19 14:07
246 查看
python运算符一些注意项
'/'浮点除,和'//'整除
单个'/'是浮点除,两个除号'//'是整除整除也适用于浮点数。但是,用整除计算浮点除的结果只是在整除的结果上浮点化,比如3.6//2.1,结果是1.0。
例子:
a = 5 for i in [1.0,1.5,2,3,4,5,6]: b= 5//i c = 5/i print a, b,c print "3.6/2.1 =",3.6/2.1 print "3.6//2.1 =",3.6//2.1
out:
5 5.0 5.0 5 3.0 3.33333333333 5 2 2 5 1 1 5 1 1 5 1 1 5 0 0 3.6/2.1 = 1.71428571429 3.6//2.1 = 1.0
相关文章推荐
- Python记录一二之数字类型
- python中的正则表达式(re模块)
- python正则
- python学习概述
- eclipse安装python插件
- 运用2to3.py将python2脚本转换为python3脚本
- Python 资源大全
- python中input()和raw_input()的区别
- Python Decorators
- Python模拟登录实战(三)
- python 抓取页面不显示图片问题
- Python接口测试
- Python -- 语法和变量
- 349. Intersection of Two Arrays [easy] (Python)
- python phantomjs+ selenium2 抓取动态js网页(版本python2.7+)
- python dict与json转换
- BeaufulSoup获取特定标签下内容的方法
- python SQLAlchemy操作mysql数据库:插入,查询,删除,更新
- python SQLAlchemy创建mysql数据库连接
- Python 进阶——重访 list (二)