How to exec a string which has an embedded '\n'?

jfong at ms4.hinet.net jfong at ms4.hinet.net
Sat Dec 30 23:57:05 EST 2017


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?

Best Regards,
Jach Fong



More information about the Python-list mailing list