How to write raw strings to Python
On Wednesday, July 5, 2017 at 8:22:13 PM UTC+5:30, Stephen Tucker wrote:
> You use
> The r in front of the string stands for raw and is intended to switch off
> the escape function of the backslash in the string. It works fine so long
> as the string doesn't end with a backslash, as in
> If you try this, you get an error message.
> On Wed, Jul 5, 2017 at 3:37 PM, Sam Chats <blahBlah at blah.org> wrote:
> > I want to write, say, 'hello\tworld' as-is to a file, but doing
> > f.write('hello\tworld') makes the file
> > look like:
> > hello world
> > How can I fix this? Thanks in advance.
> > Sam
> > --
> > https://mail.python.org/mailman/listinfo/python-list
Thanks, but I've tried something similar. Actually, I want to convert a string which I receive from a NNTP server to a raw string. So if I try something like:
raw = r"%s" % string_from_server
It doesn't work.