我正在尝试将“With open()”与 python 2.6 一起使用,它给出了错误(语法错误),而它与 python 2.7.3 一起工作正常我是否缺少某些东西或一些导入来使我的程序工作!
任何帮助,将不胜感激。
溴
我的代码在这里:
def compare_some_text_of_a_file(self, exportfileTransferFolder, exportfileCheckFilesFolder) :
flag = 0
error = ""
with open("check_files/"+exportfileCheckFilesFolder+".txt") as f1,open("transfer-out/"+exportfileTransferFolder) as f2:
if f1.read().strip() in f2.read():
print ""
else:
flag = 1
error = exportfileCheckFilesFolder
error = "Data of file " + error + " do not match with exported data\n"
if flag == 1:
raise AssertionError(error)