所以我在我的代码中生成了一个列表,现在我想根据现有文档检查它,以查看在创建新文档之前有什么不同。
这是我的尝试:
diff = ""
if File2_Loc :
File2 = open( File2_Loc , 'r' )
for line in R_List :
if line in File2 :
pass
else :
diff += ( line.strip() + " not found in old file.\n" )
for line in File2 :
if line == "***** Differences founds : *****\n" :
print( "Compared!")
break
if line in R_List :
pass
else :
diff += ( line.strip() + " not found in new file.\n" )
else :
print( "No file inputted:" )
for line in R_List :
File1.write( line )
File1.write( "***** Differences founds : *****\n" )
if diff :
File1.write( diff )
else :
File1.write( "None.\n" )
这里的问题是,R_List 中的每一行都没有在 File2 中找到,即使 100% 应该是。
我已经在寻找解决方案,但我没有看到任何解决我的问题或解决我的问题的方法。