增加open容错处理

This commit is contained in:
Jing Ling
2020-01-10 15:26:41 +08:00
parent d99cf64ae8
commit 2ff7d45348
4 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -120,7 +120,7 @@ def get_domains(target):
elif isinstance(target, str):
path = Path(target)
if path.is_file():
with open(target) as file:
with open(target, encoding='utf-8', errors='ignore') as file:
for line in file:
domain = Domain(line.strip()).match()
if domain:
@@ -189,7 +189,7 @@ def check_format(format, count):
def save_data(fpath, data):
try:
with open(fpath, 'w', encoding="utf-8", newline='') as file:
with open(fpath, 'w', encoding="utf-8", errors='ignore', newline='') as file:
file.write(data)
logger.log('ALERT', fpath)
except TypeError: