加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mybro08.py 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
張廣勤 势由心生 提交于 2022-03-14 18:25 . Initial commit
# !usr/bin/env python
# -*- coding:utf-8 _*-
"""
@Author:张广勤
@Web site: https://www.tunan.wang
@Github:www.github.com
@File:mybro04.py
@Time:2022/3/1 10:15
@Motto:不积跬步无以至千里,不积小流无以成江海!
"""
from mybro03 import Mybro
def find_key(input_dict,value):
return list({k for k,v in input_dict.items() if v==value})[0]
bro=Mybro()
bro.switchquery()
with open('zdmulu.csv','r',encoding='u8') as f:
zdmulu=f.read()
zddict=eval(zdmulu)
# zd="企业一套表统计调查制度(2022)"
zd=zddict['23']
print(zd)
zdcode=find_key(zddict,zddict['23'])
print(zdcode)
zqlist=bro.getyjnopts(zd)
print(zqlist)
with open('mulu.csv','w',encoding='u8') as f:
#f.write(zd)
f.write('')
i=1
with open('mulu.csv', 'a', encoding='u8') as f:
f.write('{')
for zq in zqlist:
j=1
bblist,bbhb=bro.getbblist1(zd,zq)
#print(bblist)
print(bbhb)
for bb in bbhb:
k=1
bb,cxmllist=bro.getquery1(bb)
# with open('mulu.csv', 'a', encoding='u8') as f:
# f.write('{')
#print(f'制度:{zd},周期:{zq},报表:{bb},查询目录:{cxml}')
for cxml in cxmllist:
if j < 10:
if k < 10:
f.write(f"'{zdcode}':'{zd}','{i}':'{zq}','{i}0{j}':{bb},'{i}0{j}0{k}':'{cxml}'")
f.write(',\n')
else:
f.write(f"'{zdcode}':'{zd}','{i}':'{zq}','{i}0{j}':{bb},'{i}0{j}{k}':'{cxml}'")
f.write(',\n')
else:
if k < 10:
f.write(f"'{zdcode}':'{zd}','{i}':'{zq}','{i}{j}':{bb},'{i}{j}0{k}':'{cxml}'")
f.write(',\n')
else:
f.write(f"'{zdcode}':'{zd}','{i}':'{zq}','{i}{j}':{bb},'{i}{j}{k}':'{cxml}'")
f.write(',\n')
k+=1
j+=1
i+=1
f.write('}')
bro.closewindow()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化