from string to raw string
Scott David Daniels
Scott.Daniels at Acm.Org
Wed Dec 15 16:59:48 EST 2004
Dan Perl wrote:
> Is there a way to convert a regular string to a raw string so that one could
> get from '\bblah' to r'\bblah' other than parsing the string and modifying
> the escapes?
Assuming you might mean something else, that something else might be:
s = r'no_tab_\t_here'
len(s.split()) == 1
len(s.decode('string_escape').split()) == 2
s = 'tab_\t_here'
len(s.split()) == 2
len(s.encode('string_escape').split()) == 1
-Scott David Daniels
Scott.Daniels at Acm.Org
More information about the Python-list
mailing list