python - 从python代码获取html输出

标签 python html

我有字典,想生成 html 页面,其中将绘制带有键和值的简单 html 表。如何从 python 代码完成?

最佳答案

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

关于python - 从python代码获取html输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1953649/

相关文章:

python - 通过 XPath 获取文本,忽略标记

html - 更改 HTML 数据列表自动完成行为

javascript - 非常简单,非常流畅,JavaScript 跑马灯

html - 为什么我的 box-shadow 不能在这些 flex children 上正确重叠?

html - Codepen 预览不应用所有 CSS

python - 我可以在 python3 中使用类似于 perl 中的 -n pipeline-option 的东西吗?

python - 在 Tkinter 中接受用户的输入

javascript - 原型(prototype)隐藏/显示

python - 正则表达式匹配 Django 项目中 URL 模式中使用的字母和数字的组合?

python - 将列表的列表转换为 numpy 数组时保持原始数据类型