user3580316
user3580316

Reputation:

Python write to file - New line

I am trying to write python code where I write to a fileand for each f.write. I want to make it write to a new line. I thought \n would do it. But right now everything is being written to one line. What am I doing wrong ?

Code (localtime, sum and value are variables)

f = open('/var/www/html/index.html','w')
f.write("<font size='35px'>"+sum+"</font>")
f.write('\n'+localtime)
f.write('\n Sist oppdatert '+value)
f.close()

Upvotes: 0

Views: 1579

Answers (1)

masnun
masnun

Reputation: 11916

Use line breaks <br/> for html line breaks:

f = open('/var/www/html/index.html','w')
f.write("<font size='35px'>"+sum+"</font>")
f.write('<br/>'+localtime)
f.write('<br/> Sist oppdatert '+value)
f.close()

Upvotes: 2

Related Questions