我是python的新手,但我已经设法编写了一段简单的代码,通过json2html模块将json数据生成为html格式。json2html.convert(json=input),这里当我传递json节点时它是工作文件,但是我应该传递一个从我的应用程序创建的json文件作为输入到json2html以生成html表format.How我可以传递任何json文件作为输入将文件转换为html表吗?
发布于 2018-05-08 21:41:54
你可以尝试使用json2table模块,至少我喜欢那样做。下面的代码创建了一个包含所有json数据表结构的html文件。
from json2table import *
import json
data = open('YOURFILE.json','r')
jsonFile = data.read()
foo = json.loads(jsonFile)
build_dir = "LEFT_TO_RIGHT"
table_attr = {"style" : "width:100%", "class" : "table table-striped"}
html = convert(foo, build_direction=build_dir,table_attributes=table_attr)
with open("YOURFILE.html", "w") as ht:
ht.write(html)https://stackoverflow.com/questions/49854765
复制相似问题