diff --git a/common/file.py b/common/file.py index c08695434ceab80c5f44075be7c122f49d064f7c..d0a2d5532c73ee28126afe3e12a9f9f321392efd 100644 --- a/common/file.py +++ b/common/file.py @@ -57,8 +57,18 @@ class FileOperation: @staticmethod def if_str_in_file(file_name, dist_str): - with open(file_name, 'r') as file: - return any(dist_str in line for line in file) + i = 0 + try: + with io.open(file_name,'r') as file: + for item in file.readlines(): + if dist_str in str(item): + i = i + 1 + if i != 0: + return True + else: + return False + except FileNotFoundError: + return False @staticmethod def get_str_num_in_file(file_name, dist_str):