Python天天美味(10) - 除法小技巧
2008-05-04 09:55
316 查看
Python中将两个整数相除,默认结果是为整数的。但我们可以通过下面的方法,使得两个整数相除的结果为小数。
from __future__ import division
print 7/3
输出结果:
2.3333333333
Python 天天美味(9) - translator
Python 天天美味(10) - 除法小技巧
Python 天天美味(11) - 可爱的大小写
Python 天天美味(12) - 条件判断的缩写
...
from __future__ import division
print 7/3
输出结果:
2.3333333333
Python 天天美味系列(总)
Python 天天美味(8) - 字符串中的字符倒转Python 天天美味(9) - translator
Python 天天美味(10) - 除法小技巧
Python 天天美味(11) - 可爱的大小写
Python 天天美味(12) - 条件判断的缩写
...
相关文章推荐
- Python天天美味(10) - 除法小技巧(转)
- Python天天美味(16) - 过滤字符串的技巧,map与itertools.imap
- Python天天美味(25) - 深入理解yield
- Python天天美味(36) - 用Python实现Spy++
- Python天天美味(31) - python数据结构与算法之插入排序
- Python天天美味(32) - python数据结构与算法之堆排序
- Python天天美味(2) - 字符遍历的艺术
- Python天天美味(3) - 字符转换(转)
- Python天天美味(14) - splitlines
- Python天天美味(18) - linecache.getline()读取文件中特定一行
- Python天天美味(23) - enumerate遍历数组
- Python天天美味(4) - isinstance判断对象类型(转)
- Python天天美味(5) - ljust rjust center
- Python天天美味(8) - 字符串中的字符倒转
- Python天天美味(11) - 可爱的大小写
- Python天天美味(33) - 五分钟理解元类(Metaclasses)[转]
- python技巧(10)
- Python天天美味(6) - strip lstrip rstrip(转)
- Python天天美味(6) - strip lstrip rstrip
- Python天天美味(12) - 条件判断的缩写