How to write raw strings to Python

Grant Edwards grant.b.edwards at gmail.com
Wed Jul 5 11:38:41 EDT 2017


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".
Seriously.
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??


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /