Python CGI prints file content in same line of browser
<p>I have file "ip"</p>

<p>file IP content:</p>

<pre><code>1.1.1.1,0.0.0.0

2.2.2.2,0.0.0.0
</code></pre>

<p>When i try to print the file using python cgi</p>

<pre><code>f.open('ip'',r')
dat = f.read()
print (dat)
</code></pre>

<p>The browser displays it as below, by printing both 1st n 2nd line in one row.</p>

<p>1.1.1.1,0.0.0.0 2.2.2.2,0.0.0.0 </p>

<p>Is there a way to print the file in same format, instead printing all content in same line?</p>

<p>Thanks</p>

<p>After having below, now o/p format is same as i/p. Thank You!</p>

<pre><code>f = open('ip', 'r')
line = f.read().replace('\n', "&lt;br&gt;")
f.close()

print line
</code></pre>

python browser cgi