各位,自己初学,弄个小脚本,有个错误无法解决
def check_file(file_new,path_file_new,cc1,cc2):
cc=cc1+'*'+cc2
o=0
file=open(path_file_new+file_new,'r',encoding='utf-8')
n=1
for line in file:
out=fnmatch.fnmatchcase(line,cc)
print(out)
print(cc)
print(line)
if out:
with open('./error_out.txt','a+',encoding='utf-8') as f:
f.write(path_file_new+file_new+' line:'+str(n)+' '+line+'\n')
o=1
n+=1
with open('./error_out.txt','a+',encoding='utf-8') as g:
g.write('\n')
file.close()
return o
但是在输出时遇到了问题
False
&&*&&
&&fdaskjfdsajfs&&
False
&&*&&
dfsafsd
False
&&*&&
cfsfsafsa
False
&&*&&
&&4444&&
True
&&*&&
&&fdaskjfdsajfs&&
文件中的第1、4行没有识别出来
只能识别最后一行