【发布时间】:2019-11-29 22:20:40
【问题描述】:
我有数据正在通过 API 获取,但数据是 HTML 格式,所以我使用 panda 将 HTML 转换为 to_dict 但是在 Django 中获取数据时,它添加了字符串环绕,我不是能够使用for循环来解析数据。如何删除字符串以便我可以获取数据。
数据:
output = fetchdata(datacenter)
## Dict format to fetch
context = {
'datacenter': datacenter,
'output': output
}
Here is the below OUTPUT:
{'datacenter': 'DC1', 'output': b"[{'Device': 'device01', 'Port': 'Ge0/0/5', 'Provider': 'L3', 'ID': 3324114459135, 'Remote': 'ISP Circuit', 'Destination Port': 'ISP Port'}, {'Device': 'device02', 'Port': 'Ge0/0/5', 'Provider': 'L3', 'ID': 334555114459135, 'Remote': 'ISP Circuit', 'Destination Port': 'ISP Port'}]\n"}
我想从输出中获取数据并以表格格式显示
【问题讨论】:
标签: python pandas list dictionary