想要处理用python抓取的数据,并且要导出到excel?

2022-08-09 社会 39阅读
import json

data = {"data":[
{"id":"1","price_data":"2017-01-06","nav":"1.516900","cumulativate_nav_withdrawa1":"1.516900"},
{"id":"1","price_data":"2017-01-02","nav":"1.516900","cumulativate_nav_withdrawa1":"1.516900"},
{"id":"1","price_data":"2017-01-03","nav":"1.516900","cumulativate_nav_withdrawa1":"1.516900"},
{"id":"1","price_data":"2017-01-05","nav":"1.516900","cumulativate_nav_withdrawa1":"1.516900"},
{"id":"1","price_data":"2017-01-07","nav":"1.516900","cumulativate_nav_withdrawa1":"1.516900"}
]}

json_str = json.dumps(data)
jsonData = json.loads(json_str)
all_data = jsonData["data"]
for item in all_data:
        #导出代码在这里实现
print item['price_data'],item['nav'],item['cumulativate_nav_withdrawa1']
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com