Python输出到html文件

waw*_*eru -5 python python-2.7

看不到整个网络都失败了.我正在运行一个python脚本,我希望它以表格格式将数据输出到我的html文件.怎么可以这样做,因为所有我得到的是CGI和所有我不知道的!

Joe*_*Joe 6

HTML文件只是一个普通文件.

with open("/tmp/myfile.html", "w") as my_file:
  my_file.write("<html><body><table>")
  for x in range(5):
    my_file.write("<tr><td>%d</td></tr>" % x)
  my_file.write("</table></body></html>")
Run Code Online (Sandbox Code Playgroud)