\r\n problem in cgi module?
peter at engcorp.com
Sat Mar 20 23:40:06 CET 2004
Jane Austine wrote:
> I'm wrote a cgi script which saves some data in a file, which is
> POSTed from a HTML page.
> The HTML page includes:
> <textarea name="text" cols="80" rows="5"></textarea>
> Then I extract the "text" as such:
> The surprise is "text" contains "\r\n" instead of "\n", when running
> on windows.
> Why does this happen, and what am I supposed to do? Isn't cgi module
> supposed to provide "universal_new_line"?
And the shortest solution for you is
text = f['text'].value.replace('\r\n', '\n')
More information about the Python-list