python-print
1 #!/usr/bin/env python 2 #-*- coding:utf-8 -*- 3 ############################ 4 #File Name: print.py 5 #Author: frank 6 #Mail: frank0903@aliyun.com 7 #Created Time:2017-09-04 13:45:59 8 ############################ 9 10 #1. 打印字符串 11 print ("His name is %s"%("Aviad")) 12 13 #2.打印整数 14 print ("He is %d years old"%(25)) 15 16 #3.打印浮点数 17 print ("His height is %f m"%(1.83)) 18 19 #4.打印浮点数(指定保留小数点位数) 20 print ("His height is %.2f m"%(1.83)) 21 22 #5.指定占位符宽度 23 print ("Name:%10s Age:%8d Height:%8.2f"%("Aviad",25,1.83)) 24 25 #6.指定占位符宽度(左对齐) 26 print ("Name:%-10s Age:%-8d Height:%-8.2f"%("Aviad",25,1.83)) 27 28 #7.指定占位符(只能用0当占位符) 29 print ("Name:%-10s Age:%08d Height:%08.2f"%("Aviad",25,1.83)) 30 31 #8.科学计数法 32 print format(0.0015,'.2e')