•        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 四舍六入五凑偶 保留一位小数的更多相关文章

  1. Python3基础 str format 位置参数与关键字参数

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  2. Python3基础 str format 输出花括号{}

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  3. 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) / ...

  4. Double 数据保留两位小数一:五舍六入

    package com; public class T2 { public static void main(String[] args) { System.out.println(calculate ...

  5. Python3基础 str translate 将指定字符转换成另一种特定字符

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  6. Python3基础 str 循环输出list中每个单词及其长度

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  7. Python3基础 str 通过拆分字符串与插入新的内容形成新的字符串

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  8. Python3基础 str while+iter+next 字符串的遍历

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  9. Python3基础 str split 用指定的字符将字符串分割

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

随机推荐

  1. Linux执行Cron Job失败,在Shell sh下执行却能成功 - 环境变量?

    博客分类: Linux linuxcrontabpermissionetc/profile环境变量  一.我们常常碰到在shell下执行某个命令能够成功,比如执行一个java程序: java -jar ...

  2. Linux 下用 crontab 设置定时执行python 程序

    Linux 下用 crontab 设置定时执行python 程序 方法/步骤   1,先大概了解crontab,/etc/crontab 就是crontab 的配置文件. crontab命令详解可以查 ...

  3. csv参数化,数据驱动

    首先我们要有一个接口测试用例存放的地方,我们这里用EXCEL模板管理,里面包含用例编号.入参.优先级.请求方式.url等等. 1:新建一个txt文件,命名为sjqd,后缀名改为csv,右键excel格 ...

  4. 【JS】自学

    JS自学网址: http://www.runoob.com/js/js-tutorial.html

  5. 01_Python 基础课程安排

    Python 基础课程安排 目标 明确基础班课程内容 课程清单 序号 内容 目标 01 Linux 基础 让大家对 Ubuntu 的使用从很 陌生 达到 灵活操作 02 Python 基础 涵盖 Py ...

  6. Spark ClassNotFoundException $$anonfun$2

    Spark ClassNotFoundException $$anonfun$2 1. 软件环境: 软件 版本 Spark 原生1.6.0 Hadoop 原生2.6.5 2. 应用场景&问题描 ...

  7. Py中的多维数组ndarray学习【转载】

    转自:http://blog.sciencenet.cn/home.php?mod=space&uid=3031432&do=blog&id=1064033 1. NumPy中 ...

  8. nodejs+express的(前端跨域请求)

    1.后端代码 var dp = 456; var back = 'callback(\{\dp\ : \ ' + dp + '\ }\)'; res.send(back); 2.前端代码 <sc ...

  9. 使用SQLMAP对网站和数据库进行SQL注入攻击

    from:http://www.blackmoreops.com/2014/05/07/use-sqlmap-sql-injection-hack-website-database/ 0x00 背景介 ...

  10. react native 示例代码

    https://react.rocks/tag/ReactNative?show=60 https://github.com/ReactNativeNews/React-Native-Apps