•        Python : 3.7.3
  •          OS : Ubuntu 18.04.2 LTS
  •         IDE : pycharm-community-2019.1.3
  •       Conda : 4.7.5
  •    typesetting : Markdown

code

"""
@Author : 行初心
@Date : 2019/7/2
@Blog : www.cnblogs.com/xingchuxin
@Gitee : gitee.com/zhichengjiu
""" def main():
book_name = "本草纲目"
book_quantity = 1
book_price = 39.1266 print("""
书名:%s
数量:%d
单价:%f
""" % (book_name, book_quantity, book_price)) # 保留三位小数
print("%.3f" % book_price) # 整数的位数不够,在左侧用0来凑。位数够的话,没有影响。
print("%04d" % book_quantity) if __name__ == '__main__':
main()

result

/home/coder/anaconda3/envs/py37/bin/python /home/coder/PycharmProjects/Base/demo.py

    书名:本草纲目
数量:1
单价:39.126600 39.127
0001 Process finished with exit code 0

source_code

def print(self, *args, sep=' ', end='\n', file=None): # known special case of print
"""
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
"""
pass

resource

  • [文档 - English] docs.python.org/3
  • [文档 - 中文] docs.python.org/zh-cn/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基础 print 格式化输出 %f %d 保留浮点数的位数 整数的位数不够零来凑的更多相关文章

  1. Python3基础 print 格式化输出 %% 输出%

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  2. Python3基础 print(,end=) 输出内容的末尾加入空格

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

  3. Python3基础 print %d 输出整数

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

  4. python基础_格式化输出(%用法和format用法)(转载)

    python基础_格式化输出(%用法和format用法) 目录 %用法 format用法 %用法 1.整数的输出 %o -- oct 八进制%d -- dec 十进制%x -- hex 十六进制 &g ...

  5. python基础_格式化输出(%用法和format用法)

      目录 %用法 format用法 %用法 1.整数的输出 %o —— oct 八进制%d —— dec 十进制%x —— hex 十六进制 1 >>> print('%o' % 2 ...

  6. Python基础篇(格式化输出,运算符,编码):

    Python基础篇(格式化输出,运算符,编码): 格式化输出: 格式:print ( " 内容%s" %(变量)) 字符类型: %s  替换字符串      %d 替换整体数字  ...

  7. pythn print格式化输出---------"%s 和 % d" 都是什么意思?

    pythn print格式化输出. %r 用来做 debug 比较好,因为它会显示变量的原始数据(raw data),而其它的符号则是用来向用户显示输出的. 1. 打印字符串 print (" ...

  8. python print格式化输出。

    python print格式化输出. 1. 打印字符串 print ("His name is %s"%("Aviad")) 效果: 2.打印整数 print ...

  9. python基础1 格式化输出

    转载自:https://www.cnblogs.com/fat39/p/7159881.html %用法 1.整数输出 %o —— oct 八进制%d —— dec 十进制%x —— hex 十六进制 ...

随机推荐

  1. zentaopms - 禅道项目管理系统部署

    概述 禅道是开源免费的项目管理软件 使用步骤 管理员 添加组织 添加用户 用户权限管理(通过分组确定权限) 产品经理 添加产品 添加模块(隶属于产品) 添加需求(隶属于模块) 添加计划(计划形成“路线 ...

  2. c# 数据类型转换

    隐式转换 byte, short, int, long, fload, double等根据其顺序向后可以隐式自动完成类型的转换,隐式转移的前提是目标类型精度高于源类型,如:short隐式转换为int, ...

  3. sql查询排序

        ORDER BY _column1, _column2; /* _column1升序,_column2升序 */   ORDER BY _column1, _column2 DESC; /* ...

  4. commons-dbutils使用介绍,commons-dbutils是JDBC的替代品

    commons-dbutils是Apache开源组织提供的用于操作数据库的工具包.今天为大家介绍一下该包的常用方法. 对于数据库的操作无外乎增删改查,而增删改本质上可以归为一类,操作方式相同,只是SQ ...

  5. js实现大文件上传分片上传断点续传

    文件夹上传:从前端到后端 文件上传是 Web 开发肯定会碰到的问题,而文件夹上传则更加难缠.网上关于文件夹上传的资料多集中在前端,缺少对于后端的关注,然后讲某个后端框架文件上传的文章又不会涉及文件夹. ...

  6. learning java AWT 手绘窗口

    import java.awt.*;port java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import jav ...

  7. (2)Angular的开发

    什么是 ReactNative应用, 小程序与RN的关系 native端优化 Js端优化 ReactNative是? 用JavaScript来写App,性能好 异步编程 请点赞!因为你的鼓励是我写作的 ...

  8. 原创:Solr Wiki 中关于Suggester(搜索推荐)的简单解读

       Solr Wiki Suggester Suggester - a flexible "autocomplete" component.(搜索推荐) A common nee ...

  9. 描述yeild作用

    保存当前运行状态(断点),然后暂停执行,即将函数挂起 将yeild关键字后面表达式的值作为返回值返回,此时可以理解为起到了return的作用,当使用next().send()函数让函数从断点处继续执行 ...

  10. eclipse快捷键及设置【转】

    1.Eclipse设置新建菜单初始项 windows-->Perspective-->Customize Perspective--> 2.Eclipse快捷键 1. ctrl+sh ...