发布于2019-08-07 19:27 阅读(1007) 评论(0) 点赞(1) 收藏(4)
1、环境
python2.7
2、库
xlwt、demjson、json
3、code
# -*- coding: utf-8 -*- import xlwt,demjson,json if __name__ == '__main__': '''读取excel''' x = 0 #初始值 横轴 y = 0 #初始值 数轴 wbk = xlwt.Workbook() sheet = wbk.add_sheet('sheet 1') with open('api.json', 'r') as t: data = t.read().decode('utf-8') apilist = data.strip(',').split('+') for v in apilist: string = v.replace("'", '"') dictDat = demjson.decode(string.encode('utf-8')) # print dictDat[u'methodsName'] sheet.write(x,y,u'内容') sheet.write(x,y+1,dictDat[u'desc']) sheet.write(x+1,y,u'URL') sheet.write(x+1,y+1,dictDat[u'path']) ## 参数 sheet.write(x+2,y, u'参数') sheet.write(x+2,y+1,u'默认值') sheet.write(x+2,y+2,u'类型') sheet.write(x+2,y+3,u'说明') ## 开始添加参数 dict1 = dictDat[u'params'] vv = 1 for k,v in dict1.items(): sheet.write(x+2+vv, y, k) v = ( u'空' if v == '' else v) ss = ( u'字符串' if v == u'空' else u'数值') sheet.write(x+2+vv, y+1, v) sheet.write(x+2+vv, y+2, ss) sheet.write(x+2+vv, y+3, '') vv += 1 x = x + 4 + len(dict1) wbk.save('api.xlsx')
作者:小兔子乖乖
链接:https://www.pythonheidong.com/blog/article/12413/5e2f6a47fdf4515bc1f2/
来源:python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!