python提取内容写入txt,生成了txt文件但是为空,请问要怎么解决啊?
各位大神,写入txt,生成了txt文件但是为空,请问要怎么解决啊?with open("PATH.txt","w") as f:
while True:
for i in range(self.ldir_txt):
print(self.dirname_txt[i])
total=len(self.list_txt[i])
for loop_menu in range(total):
if seekA in self.list_txt[i][loop_menu]:
f.write('##########################'+'\n'+\
str(self.dirname_txt[i])+'\n'+\
'##########################'+'\n')
for loop_out in range(loop_menu,0,-1):
if "#" in self.list_txt[i][loop_out] or 'exit' in self.list_txt[i][loop_out]:
for loop_in in range(loop_out,total):
print(self.list_txt[i][loop_in])
f.write(self.list_txt[i][loop_in])
if "#" in self.list_txt[i][loop_in] or 'exit' in self.list_txt[i][loop_in] :
break
if "#" in self.list_txt[i][loop_out] or 'exit' in self.list_txt[i][loop_out]:
break
break
if seekA=='0':
break
f.close()
return f