diff --git a/common/file.py b/common/file.py index 2184699d90d05ca56f05d571f30556fb157ca688..8429223c7fc7ff472297030d8657bc67acaf504d 100644 --- a/common/file.py +++ b/common/file.py @@ -58,15 +58,8 @@ class FileOperation: @staticmethod def if_str_in_file(file_name, dist_str): - i = 0 - 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 + with open(file_name, 'r') as file: + return any(dist_str in line for line in file) @staticmethod def get_str_num_in_file(file_name, dist_str):