码迷,mamicode.com
首页 > 编程语言 > 详细

Python之变量和打印

时间:2016-02-15 14:49:23      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

#coding:utf-8
name = ‘Zed A. Shaw‘
age = 8.123 # not a lie
height = 74 # inches
weight = 180 # lbs
eyes = ‘Blue‘
teeth = ‘White‘
hair = ‘Brown‘

print "His name is %s" %name
#这里可以将常量也以这种方式打印出来
#格式化字符数字宽度为10,不够前面用0代替,精度为2
print "His age is %010.2f" %10
#r是不管是什么都打印出来   

print "His height is %r inches and weight is %d lbs" %(height,weight)
print "If I add %d,%d and %d is %d" %(age,height,weight,age+height+weight)

http://www.douban.com/note/269665597/,这个里有比较全的格式化字符讲解

Python之变量和打印

标签:

原文地址:http://www.cnblogs.com/67lmq/p/5190413.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!