Keldos commited on
Commit
4b48360
1 Parent(s): b25d3e2

fix: specify encoding when saving HTML

Browse files

Solve the possible issue of displaying garbled codes in macOS

crazy_functions/对话历史存档.py CHANGED
@@ -13,7 +13,7 @@ def write_chat_to_file(chatbot, history=None, file_name=None):
13
  os.makedirs('./gpt_log/', exist_ok=True)
14
  with open(f'./gpt_log/{file_name}', 'w', encoding='utf8') as f:
15
  from theme import advanced_css
16
- f.write(f'<head><title>对话历史</title><style>{advanced_css}</style></head>')
17
  for i, contents in enumerate(chatbot):
18
  for j, content in enumerate(contents):
19
  try: # 这个bug没找到触发条件,暂时先这样顶一下
 
13
  os.makedirs('./gpt_log/', exist_ok=True)
14
  with open(f'./gpt_log/{file_name}', 'w', encoding='utf8') as f:
15
  from theme import advanced_css
16
+ f.write(f'<!DOCTYPE html><head><meta charset="utf-8"><title>对话历史</title><style>{advanced_css}</style></head>')
17
  for i, contents in enumerate(chatbot):
18
  for j, content in enumerate(contents):
19
  try: # 这个bug没找到触发条件,暂时先这样顶一下