amerFilename1=['03-01-2018 .txt','03-36-2018.txt']
for mo in amerFilename1:
print(mo)
if mo == None:
continue
print(hello)
下面的代码可以打印出 hello
amerFilename1=['03-01-2018.txt','03-36-2018.txt']
for mo in amerFilename1:
print(mo)
if mo == None:
continue
print('hello')
import shutil, os, re
datePattern = re.compile(r"""^(.?) # all text before the date
((0|1)?\d)- # one or two digits for the month
((0|1|2|3)?\d)- # one or two digits for the day
((19|20)\d\d) # four digits for the year
(.?)$ # all text after the date
""", re.VERBOSE)
for amerFilename in os.listdir('.'):
#符合表达式的内容赋值给mo
mo = datePattern.search(amerFilename)
#print(mo)
if mo == None:
continue
print('hello')
‘’‘
目录中已经有了'03-01-2018.txt','03-36-2018.txt'两个符合表达式的文件,但是不能走到continue后面去。我用Debug模式查看到,表达式没有问题可以查询到文件并且给了mo,但是在if是mo一致为None
’‘’