Python之变量和打印

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python之变量和打印相关的知识,希望对你有一定的参考价值。

#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之变量和打印的主要内容,如果未能解决你的问题,请参考以下文章

Python之打印变量

python编程之变量和简单的数据结构

JUC并发编程 共享模式之工具 JUC CountdownLatch(倒计时锁) -- CountdownLatch应用(等待多个线程准备完毕( 可以覆盖上次的打印内)等待多个远程调用结束)(代码片段

python常用代码

python调试之pdb调试工具

JAVA之AOP