【Python】保留有效位
2014-03-11 22:18
197 查看
a=b/float(c) #例如此时 a=4.323232324343 #输出到文件中 outputFile.write(str('%.3f'%a)+'\n') #保留小数点三位有效数字 #直接输出 print 'a=%0.3f, b=%d'%(a,b)
相关文章推荐
- python正则分组匹配小例
- virtualenv、pip备忘
- python 实现梯度下降
- python按行读取文件,如何去掉换行符"\n"
- Python核心编程——Chapter9
- Python核心编程——Chapter9
- Python调用win32api
- 《使用python进行自然语言理解》学习笔记二
- 使用 python Matplotlib 库绘图
- OpenCV Python 在Windows下的安装
- 安装python组件
- Non-ASCII character python文件中有中文编码出错 解决办法
- python开发工作环境
- Python正则表达式
- python script传参数
- fabric批量管理主机
- Python MySQL OperationalError: (1054, "Unknown column 'XX' in 'where clause'")
- Python break语句详解
- Python学习笔记一
- Python2.x与Python3.x的区别