How to exec a string which has an embedded '\n'?
Random832
random832 at fastmail.com
Sun Dec 31 00:25:36 EST 2017
More information about the Python-list mailing list
Sun Dec 31 00:25:36 EST 2017
- Previous message (by thread): How to exec a string which has an embedded '\n'?
- Next message (by thread): How to exec a string which has an embedded '\n'?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Dec 30, 2017, at 23:57, jfong at ms4.hinet.net wrote: > I have a multiline string, something like '''...\nf.write('\n')\n...''' > when pass to exec(), I got > SyntaxError: EOL while scanning string literal > > How to get rid of it? Use \\n for this case, since you want the \n to be interpreted by the exec parser rather than the newline being part of the string.
- Previous message (by thread): How to exec a string which has an embedded '\n'?
- Next message (by thread): How to exec a string which has an embedded '\n'?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list