修复pdf翻译的问题

This commit is contained in:
505030475
2023-05-23 00:05:00 +08:00
parent 6d557b3c34
commit db16e85d8c
2 changed files with 101 additions and 13 deletions

View File

@@ -168,14 +168,17 @@ def write_results_to_file(history, file_name=None):
with open(f'./gpt_log/{file_name}', 'w', encoding='utf8') as f:
f.write('# chatGPT 分析报告\n')
for i, content in enumerate(history):
try: # 这个bug没找到触发条件暂时先这样顶一下
if type(content) != str:
content = str(content)
try:
if type(content) != str: content = str(content)
except:
continue
if i % 2 == 0:
f.write('## ')
f.write(content)
try:
f.write(content)
except:
# remove everything that cannot be handled by utf8
f.write(content.encode('utf-8', 'ignore').decode())
f.write('\n\n')
res = '以上材料已经被写入' + os.path.abspath(f'./gpt_log/{file_name}')
print(res)