What is the best way to handle a command line argument that includes an escape sequence like \n?

Steven Bethard steven.bethard at gmail.com
Thu Mar 3 01:35:41 CET 2005

Joe wrote:
> It appears that Python treats the comand line string as a raw string.
> what is the best way to work around the issue?

You probably want to use str.decode with the encoding 'string_escape'[1]

py> s = r'\n\t'
py> s
py> s.decode('string_escape')



More information about the Python-list mailing list