[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to write raw strings to Python

On 2017-07-05, 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:
> How can I fix this?

That depends on what you mean by "as-is".


Do you want the single quotes in the file?  Do you want the backslash
and 't' character in the file?

When you post a question like this it helps immensely to provide an
example of the output you desire.

Grant Edwards               grant.b.edwards        Yow! Is it 1974?  What's
                                  at               for SUPPER?  Can I spend
                              gmail.com            my COLLEGE FUND in one
                                                   wild afternoon??