How do you input 2 files then output them in python?
I have a code written for a webpage and I need to know how to take 2 data files and import them into an array then output the da开发者_如何学Cta in a table on my html site.
the 2 data files are txt files that are on my computer
Well I'm going to take a guess that you want to just create an html table that has 1 line per data line in the text file.
file1=open("input1.txt",'rU')
file2=open("input2.txt",'rU')
lines = file1.readlines() + file2.readlines()
html = "<html>\n<body>\n<table>"
for line in lines:
html += "<tr><td>" + line + "</td></tr>\n"
html += "</table>\n</body>\n</html>"
output = open('output_file.html','w')
output.write(html)
I don't know if that is what you were looking for, but that does what I said above.
精彩评论