•        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. flask中cookie,session的存储,调用,删除 方法(代码demo)

    # -*- encoding: utf-8 -*- # cookie,session的存储,调用,删除 from flask import Flask,make_response,request,se ...

  2. Unity-反编译由IL生成的DLL文件

        本文由博主SunboyL原创,转载请注明出处:http://www.cnblogs.com/xsln/p/DLL_DeCompilation.html     在Unity实际开发过程中,我们 ...

  3. dedecms自增标签[field:global.autoindex/]的运用

    用bootstrap建站时用到幻灯片切换模块,里面有个active(下面代码中的data-slide-to="0"),其余的按顺序递增(1,2),如果用dedecms就可以用aut ...

  4. [vue]组件最佳实战

    [vue]全局组件和局部组件(嵌套+props引用父组件数据) [vue]组件篇 [vue]组件的创建(componet)和销毁(keep-alive缓存)和父子dom同步nextTick [vue] ...

  5. Tomcat重启session失效

    在Tomcat的目录下找到context.xml,取消掉<Manager pathname="" /> 这句的注释.

  6. servlet07

    1.session验证 可以防止非登录的用户,通过在地址栏中输入地址,访问受保护的页面 step1.在用户登录成功之后,将用户的信息保存到session中 step2.在访问受保护的页面时,校验ses ...

  7. Matlab中图像处理实例:灰度变换,空域滤波,频域滤波,傅里叶变换的实现

    http://blog.sciencenet.cn/blog-95484-803140.html % %图像灰度变换 % f = imread('E:\2013第一学期课程\媒体计算\实验一\Img\ ...

  8. #C++初学记录(算法2)

    A - Game 23 Polycarp plays "Game 23". Initially he has a number n and his goal is to trans ...

  9. PKU2418_树种统计(map应用||Trie树)

    Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or nu ...

  10. Verilog篇(四)时序模型

    时序模型:仿真器的时间推进模型,它反映了推进仿真时间和调度事件的方式. 1)门级时序模型:适用于分析所有的连续赋值语句,过程连续赋值语句,门级原语,用户自定义原语. 特点:任意时刻,任意输入变化都将重 ...