郭书宇 发表于 2020-4-15 09:59:51

for循环怎么没有执行? 求助

import re
zihao=input('请输入字号')

pathdir=input('文件路径')
for (root, dirs, files) in os.walk(pathdir):
    for name in files:
      try:
            txt1=open(os.path.join(root,name),'r')
            txtread=txt1.read()
            txt1=txt1.readlines()
            if re.match(zihao, txtread):
                print(os.path.join(root,name))
                continue
            for i in txt1:
                print('1')
                for a in re.finditer(zihao, i):
                  print('1')
                  print(a.span())
      except UnicodeDecodeError :
            continue



            

永恒的蓝色梦想 发表于 2020-4-15 10:00:14

求助请发求助帖

郭书宇 发表于 2020-4-15 10:04:50

永恒的蓝色梦想 发表于 2020-4-15 10:00
求助请发求助帖

这不是求助贴吗?
页: [1]
查看完整版本: for循环怎么没有执行? 求助