Random832於 2017年12月31日星期日 UTC+8下午1時25分50秒寫道: > On Sat, Dec 30, 2017, at 23:57, jf...@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.
Thank you, it's very helpful. This answer makes me think about '\' more thoughtful:-) --Jach -- https://mail.python.org/mailman/listinfo/python-list