t205.py
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 i = 4
00019 s1 = "test %d" % i
00020 s2 = "test %d" % (i,)
00021 assert s1 == s2 == "test 4"
00022
00023 i = 205
00024 s1 = "test t%03d" % i
00025 s2 = "test t%03d" % (i,)
00026 print s1
00027 assert s1 == s2 == "test t205"
00028
00029 f = -3.14
00030 s1 = "test %f this" % f
00031 s2 = "test %f this" % (f,)
00032 assert s1 == s2 == "test -3.140000 this"
00033
00034 f = -3.14
00035 s1 = "test %1.2f" % f
00036 s2 = "test %1.2f" % (f,)
00037 assert s1 == s2 == "test -3.14"
00038
00039 s = "this"
00040 s1 = "test %s string" % s
00041 s2 = "test %s string" % (s,)
00042 assert s1 == s2 == "test this string"
00043
00044 d = 4
00045 s = "score"
00046 f = 7.0
00047 s = "%d %s and %.0f years ago" % (d,s,f,)
00048 print s
00049 assert s == "4 score and 7 years ago"