Python3基础 str format 四舍六入五凑偶 保留一位小数
- Python : 3.7.0
- OS : Ubuntu 18.04.1 LTS
- IDE : PyCharm 2018.2.4
- Conda : 4.5.11
- typesetting : Markdown
code
coder@Ubuntu:~$ source activate py37
(py37) coder@Ubuntu:~$ ipython
Python 3.7.0 (default, Jun 28 2018, 13:15:42)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: # 四舍
In [2]: "{0:.1f}".format(27.54)
Out[2]: '27.5'
In [3]: "{0:.1f}".format(27.64)
Out[3]: '27.6'
In [4]:
In [4]: # 六入
In [5]: "{0:.1f}".format(27.56)
Out[5]: '27.6'
In [6]: "{0:.1f}".format(27.66)
Out[6]: '27.7'
In [7]:
In [7]: # 五凑偶
In [8]: "{0:.1f}".format(27.55)
Out[8]: '27.6'
In [9]: "{0:.1f}".format(27.65)
Out[9]: '27.6'
In [10]: exit
(py37) coder@Ubuntu:~$ source deactivate
coder@Ubuntu:~$
resource
- [文档] docs.python.org/3
- [规范] www.python.org/dev/peps/pep-0008
- [规范] zh-google-styleguide.readthedocs.io/en/latest/google-python-styleguide/python_language_rules
- [源码] www.python.org/downloads/source
- [ PEP ] www.python.org/dev/peps
- [平台] www.cnblogs.com
- [平台] gitee.com
Python具有开源、跨平台、解释型、交互式等特性,值得学习。
Python的设计哲学:优雅,明确,简单。提倡用一种方法,最好是只有一种方法来做一件事。
代码的书写要遵守规范,这样有助于沟通和理解。
每种语言都有独特的思想,初学者需要转变思维、踏实践行、坚持积累。
Python3基础 str format 四舍六入五凑偶 保留一位小数的更多相关文章
- Python3基础 str format 位置参数与关键字参数
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str format 输出花括号{}
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Math.Round四舍六入五取偶Math.Ceiling只要有小数都加1Math.Floor总是舍去小数
1.Math.Round:四舍六入五取偶 引用内容 Math.Round(0.0) //0Math.Round(0.1) //0Math.Round(0.2) //0Math.Round(0.3) / ...
- Double 数据保留两位小数一:五舍六入
package com; public class T2 { public static void main(String[] args) { System.out.println(calculate ...
- Python3基础 str translate 将指定字符转换成另一种特定字符
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str 循环输出list中每个单词及其长度
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str 通过拆分字符串与插入新的内容形成新的字符串
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str while+iter+next 字符串的遍历
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 str split 用指定的字符将字符串分割
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
随机推荐
- 自动布局又出问题-HPPGCTableViewCell
[self.firstComment mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(sel ...
- Django - 学习目录
Django 基础 web应用/http协议/web框架 Django简介 Django - 路由层(URLconf) Django - 视图层 Django - 模板层 Django - 模型层 - ...
- curl获取公网IP地址
curl ip.cn curl cip.cc https://blog.csdn.net/orangleliu/article/details/51994513 https://blog.csdn.n ...
- 2018/04/03 每日一个Linux命令 之 lastb/last
今天还在想暴力破解一个服务器是怎么完成的....... -- lastb功能说明:列出登录系统失败的用户相关信息. -- 单独执行 lastb 时候,它会读取/var/log 下的 btmp 文件,输 ...
- less语言特性(二) —— 混合
在 LESS 中我们可以定义一些通用的属性集为一个 class,然后在另一个 class 中去调用这些属性,下面有这样一个 class: 1 2 3 4 .bordered { border-top: ...
- Mysql中Left Join 与Right Join 与 Inner Join 与 Full Join的区别
看看Left Join 与Right Join 与 Inner Join 与 Full Join对表进行操作后得到的结果. 在数据库中新建两张表,并插入要测试的数据. 新建表: USE [Test] ...
- linux上mysql安装详细教程
所有平台的MySQL下载地址为: MySQL 下载. 挑选你需要的 MySQL Community Server 版本及对应的平台. MySQL - MySQL服务器.你需要该选项,除非你只想连接运行 ...
- 解决idea工具下tomcat中文乱码问题
在运行/调试 配置对话框的Startup/Connection面板中, 勾选Pass environment variables. 并添加一个environment variable, Name填 J ...
- leadJS初构建
目录: 1. 面向对象篇 2. 数据结构篇 3. 全局函数篇 4. APICloud篇 1. 面向对象篇 JS原本无法进行程序员世界的面向对象编程,故此对JS封装成一种具有面向对象编程能力的JS. / ...
- uboot中fdt命令的使用
转载:https://blog.csdn.net/voice_shen/article/details/7441894 依linux community的要求,从linux-3.5后,新提交的code ...