CR LF
Steve Holden
sholden at holdenweb.com
Wed Aug 30 07:34:53 EDT 2000
Simon Faulkner wrote:
>
> Hi All,
>
> I am printing a string to a html page and the string is correctly
> stored in the MySQL database as
>
> >>
> This string wraps onto 3 lines
> Line2
> Line3
> <<
>
> But, of course, it comes out on the web page as
>
> >>
> This string wraps onto 3 lines Line2 Line3
> <<
>
> I need to replace each return with a <BR> as I print the field.
>
> Any ideas? - what is the smart way to do this?
>
> Simon
>
> Simon Faulkner
Simplest approach would be:
>>> import string
>>> dbresult = """This string wraps onto 3 lines
Line2
Line3
"""
>>> string.replace(dbresult, "\n", "<BR>\n")
'This string wraps onto 3 lines<BR>\012Line2<BR>\012Line3<BR>\012'
regards
Steve
--
Helping people meet their information needs with training and technology.
703 967 0887 sholden at bellatlantic.net http://www.holdenweb.com/
More information about the Python-list
mailing list