37,719
社区成员
发帖
与我相关
我的任务
分享
#已经加入了import os,db为字典序列
def doc():
bpath=r'd:\program files\python\lib'
files=os.listdir(bpath)
for eachfile in files:
if os.path.splitext(eachfile)[1]=='.py':
mpath=os.path.join(bpath,eachfile)
sign='"""'
mpath.encode('utf-8','ignore')
f=open(mpath,'rb')
text=f.read()
lpos=text.find(sign)
if lpos!=-1:
rpos=text.find(sign,lpos+1)
doc=text[lpos+1:rpos]
else:
doc=''
db.setdefault(os.path.basename(eachfile),doc)
f.close()