问题描述
我一直在使用Python的JSON库来从使用Python的JSON文件中获取数据。
infoFromJson = json。加载(jsonfile)
我完全理解如何在Python中使用JSON文件。不过,我试图找到一种很好的格式化JSON格式的方法。
我更喜欢将JSON转换为嵌套的HTML表格格式。
我发现Python的,它正是我刚刚描述的。
但是,当我运行它们提供的脚本时,它实际上并不输出任何内容。
有没有人有过使用此工具的经验?或者是否有人对替代方案有任何建议?
pre> infoFromJson = json.loads(jsonfile)
print json2html.convert(json = infoFromJson)
来自 json2html.convert
的结果是一个字符串。
如果您没有模块的问题:
$ pip install json2html
更多示例。
I've been using the JSON library for Python to get data from JSON files using Python.
infoFromJson = json.loads(jsonfile)
I fully understand how to work with JSON files in Python. However, I am trying to find a way to format JSON format in a nice way.
I prefer to convert the JSON into a nested HTML table format.
I found json2html for Python, which does exactly what I just described.However, it does not actually output anything when I run the script they provide.
Has anyone had experience with this tool? Or does anyone have suggestions for alternatives?
Try the following:
infoFromJson = json.loads(jsonfile)
print json2html.convert(json = infoFromJson)
The result from json2html.convert
is a string.
If you don't have json2html module:
$ pip install json2html
More examples here.
这篇关于在Python中将JSON转换为HTML表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!