Hello all.

I have a txt file which has a number of links and i need to save this file as a .html page in my webserver.How do i append <html><body><title></title>'Content of the file'</body> </html> tags to the start and end of a file so that it is saved as a html file and can be viewed on the webserver

It could be as simple as this:

text = """\
Hello all.  I have a text file which has a number of links ...
"""

html = "<title></title><html><body>" + text + "</body> </html>"

print html

fout = open("test_html.htm", "w")
fout.write(html)
fout.close()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.