String Formating
eharetea

Methods for string formatting in Python.

String formatting!

Date Created:Friday December 29th, 2006 03:41 AM
Date Modified:Friday August 01st, 2008 01:30 AM

>>> "that is %s cool!" % ('really')
'that is really cool!'

>>> "%d -- %06d" % (x,x)
'123 -- 000123'

>>> print '-'*80
--------------------------------------------------------------------------------

>>> a = '123' + '234' 
>>> a
'123234'

# raw strings
>>> s = r'this \nstring\tis\nraw'
>>> s
'this \\nstring\\tis\\nraw'

# this is unicode
>>> s = u'this\nis\tunicode'
>>> s
u'this\nis\tunicode'