import os
res = []
for root, dirs,files in os.walk(“C:\Users\admin\Desktop\python代码\python中”) :
for i in files:
print(i)
name,suf = os.path.splitext(i)
if suf ==".py":
res.append(os.path.join(root,i))
#print(res)
for i in res:
with open (i,“r+”,encoding=‘UTF-8’) as f:
# with open (i,“r”,encoding=‘UTF-8’) as f:
#print(i)
s = str(f.read())
s = s + “\n”+ str(i)
print(s)
with open (“C:\Users\admin\Desktop\testmid.txt”,“a+”,encoding=‘UTF-8’) as c:
c.write(s+’\n’)