常用链接

统计

最新评论

Python study -格式化字符串

字符串格式化与字符串连接的比较

>>>count =6
>>>print "count is %d" % (count,)
count is 6
>>>
print "count is %s" % (count,)
count is 6
>>>
print "count is %f" % (count,)
count is 6.000000
>>>
print "count is %.2f" % (count,)
count is 6.00
>>>
print "count is " +count
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects

posted on 2009-05-14 11:50 九宝 阅读(248) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: