Python学习入门基础教程(learning Python)--1.2.3 Python格式化输出百分比
2013-08-22 14:52
1096 查看
在有些情况下,需要百分比输出数据,我们可以继续使用Python内建函数format来实现百分比的数据输出。
>>> print(format(0.5236, '.2%'))
其结果如下所示。
>>> print(format(0.5, '.0%'))格式控制字里的0的含义是小数点后无小数,即只保留整数部分,其结果如下所示。
>>>print(format(0.5236, '.2%'))结果如下所示。
相关文章推荐
- Python学习入门基础教程(learning Python)--1.2.2 Python格式化输出基础 .
- Python学习入门基础教程(learning Python)--1.2.4 Python格式化输出科学计数 .
- Python学习入门基础教程(learning Python)--1.2.1 Python输出语句print基本使用 .
- Python学习入门基础教程(learning Python)--5.6 Python读文件操作高级
- Python学习入门基础教程(learning Python)--2.2.1 Python下的变量解析 .
- Python学习入门基础教程(learning Python)--3.3 分支语句的条件表达式详解 .
- Python学习入门基础教程(learning Python)--5 Python文件处理
- Python学习入门基础教程(learning Python)--5.3 Python写文件基础
- Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
- Python学习入门基础教程(learning Python)--3.3.2 Python的关系运算
- Python学习入门基础教程(learning Python)--8.1 字典数据添加与删除
- Python学习入门基础教程(learning Python)--2.3 Python自定义函数传参函数设计
- Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
- Python学习入门基础教程(learning Python)--2.3 Python自定义函数传参
- Python学习入门基础教程(learning Python)--3.3.3 Python逻辑关系表达式
- Python学习入门基础教程(learning Python)--2.2.2 Python全局和局部变量 .
- Python学习入门基础教程(learning Python)--2.3.1 Python传参函数设计
- Python学习入门基础教程(learning Python)--3.3.1 Python下的布尔表达式
- Python学习入门基础教程(learning Python)--3.3.4 Python的if-elif-else语句
- Python学习入门基础教程(learning Python)--2.3.2Python函数实参详解