标题:python提取内容写入txt,生成了txt文件但是为空,请问要怎么解决啊?
取消只看楼主
csm_june
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-1-15
结帖率:100%
已结贴  问题点数:20 回复次数:1 
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
搜索更多相关主题的帖子: txt break if 文件 for 
2020-01-15 15:32
csm_june
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-1-15
得分:0 
回复 楼主 csm_june
已经解决啦,谢谢
2020-01-15 17:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-498940-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.329756 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved