Ray's playground

 

Recipe 1.6. Combining Strings(Python Cookbook)

string
 1 >>> import operator
 2 >>> pieces = ['a''b''c']
 3 >>> largestring = reduce(operator.add, pieces)
 4 >>> largestring
 5 'abc'
 6 >>> faststring = ''.join(pieces)
 7 >>> faststring
 8 'abc'
 9 >>> formatstring = '%s is %s' % ('ray''coding')
10 >>> formatstring
11 'ray is coding'

 

posted on 2010-12-19 11:43  Ray Z  阅读(140)  评论(0编辑  收藏  举报

导航