【python】 The different between ' %r ' and ' %s '

for example:

 test = """hello,\nworld"""
 print "this is test1: %s" %test
 print "this is test2: %r" %test
输出:
   this is test1: hello,
   world
   this is test2: 'hello,\nworld'
 
由此可见,在python中格式化字符%r,表示打印的是对象,什么都打印
posted @ 2014-03-27 20:26  xrange  阅读(319)  评论(0编辑  收藏  举报