Browse Source

发票识别服务项目 初始化

xubo 1 year ago
parent
commit
42c9117118
3 changed files with 4 additions and 2 deletions
  1. BIN
      .DS_Store
  2. 0 0
      logs/spider-terminal_2024-07-03.log
  3. 4 2
      tools/document_util.py

BIN
.DS_Store


+ 0 - 0
logs/spider-terminal_2024-07-03.log


+ 4 - 2
tools/document_util.py

@@ -1,3 +1,4 @@
+import json
 import os
 import os
 from datetime import datetime
 from datetime import datetime
 
 
@@ -27,5 +28,6 @@ class TextFileWriter:
     def write_to_file(self, data):
     def write_to_file(self, data):
         date_str = datetime.now().strftime('%Y-%m-%d')
         date_str = datetime.now().strftime('%Y-%m-%d')
         filename = f"{self.filepath}/{date_str}.txt"
         filename = f"{self.filepath}/{date_str}.txt"
-        with open(filename, 'a') as file:  # 'a' 模式可以在文件存在的情况下继续写入内容
-            file.write(data + '\n')
+        with open(filename, 'a', encoding='utf-8') as file:  # 指定编码为 'utf-8'
+            json.dump(data, file, ensure_ascii=False)  # 禁用 ASCII 转义
+            file.write('\n')