python 从python代码获取html输出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1953649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 23:25:46 来源:igfitidea点击:
Get html output from python code
提问by yart
I have dictionary and would like to produce html page where will be drawn simple html table with keys and values. How it can be done from python code?
我有字典,并想生成 html 页面,其中将绘制带有键和值的简单 html 表。如何从 python 代码中完成?
回答by rui
output = "<html><body><table>"
for key in your_dict:
output += "<tr><td>%s</td><td>%s</td></tr>" % (key, your_dict[key])
output += "</table></body></html>
print output
回答by jbochi
回答by luc
You maybe interested by markup see http://markup.sourceforge.net/
您可能对标记感兴趣,请参阅http://markup.sourceforge.net/