I have upgraded to Python 3 and can't figure out how to convert backslash escaped newlines to HTML.
The browser renders the backslashes literally, so "\n" has no effect on the HTML source. As a result, my source page is all in one long line and impossible to diagnose.
normally I do like this s=s.replace("\n","<br />\n")
because
<br />
is needed in web page display and
\n
is needed in source display.
just my 2 cents
The solution is:
#!/usr/bin/python
import sys
def print(s): return sys.stdout.buffer.write(s.encode('utf-8'))
print("Content-type:text/plain;charset=utf-8\n\n")
print('晉\n')
See the original discussion here: http://groups.google.com/group/comp.lang.python/msg/f8bba45e55fe605c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With