0

I wrote a python code that returns a StringIO which consists of several lines extracted from a runlog. Then it writes this string in a .txt file and an html page.

the format of the lines in the .txt file shows every line of the runlog seperately, which is how I want the format to be. However, in the html page, all the lines are merged together instead of being separate...

How can i solve this problem in the html page?

bush
  • 9
  • 4
  • 4
    By learning about HTML? Specifically the [`
    `](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre) element?
    – Boldewyn Nov 06 '14 at 14:46
  • You're welcome! (Also welcome to StackOverflow!) For your next questions, please read ["How do I ask a good question"](http://stackoverflow.com/help/how-to-ask) in this site's FAQ. When the question lacks basic understanding, that might have been acquired with 10 minutes worth of Googling, the question is likely to be closed without anyone caring to answer it. Specifically, in this case you should've looked up basic HTML first elsewhere on the web. If you're stuck, come back and ask any time (say explicitly what you achieved already!), but, please, not the other way round. – Boldewyn Nov 10 '14 at 10:11

1 Answers1

0

This is really an html whitespace / newline formatting question. The easiest solution is wrap around your output with <pre> tag, like

<pre>
line1
line2
line3
...
</pre>

Alternatively, you can wrap each line with a <p> tag, or add a <br> tag after each line.

Read more about this topic here.

Ying Xiong
  • 4,578
  • 8
  • 33
  • 69
  • Thank you Ying Xiong! I was confused about how to integrate html in a python code.. now the code works! – bush Nov 10 '14 at 09:46