修复 Windows 编码问题导致生成失败
Windows 默认编码为 GBK,Python stdout 输出含中文的 JSON 时 Node.js 端无法正确解析,导致批量生成操作静默失败。 - python/main.py:启动时强制 stdin/stdout 使用 UTF-8 - templateIpc.js:spawn 传入 PYTHONUTF8=1,改用 Buffer 拼接后 UTF-8 解码 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a4d1218d21
commit
6b2c87dc18
@@ -1,5 +1,10 @@
|
||||
import sys
|
||||
import json
|
||||
import io
|
||||
|
||||
# Windows 默认编码不是 UTF-8,强制设置
|
||||
sys.stdin = io.TextIOWrapper(sys.stdin.buffer, encoding="utf-8")
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", line_buffering=True)
|
||||
|
||||
def main():
|
||||
for line in sys.stdin:
|
||||
|
||||
Reference in New Issue
Block a user