mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2026-02-06 23:21:33 +08:00
fix: 'utf-8' codec can't decode error
This commit is contained in:
11
main.py
11
main.py
@@ -17,6 +17,17 @@
|
||||
# 详细许可条款请参阅项目根目录下的LICENSE文件。
|
||||
# 使用本代码即表示您同意遵守上述原则和LICENSE中的所有条款。
|
||||
|
||||
import sys
|
||||
import io
|
||||
|
||||
# Force UTF-8 encoding for stdout/stderr to prevent encoding errors
|
||||
# when outputting Chinese characters in non-UTF-8 terminals
|
||||
if sys.stdout and hasattr(sys.stdout, 'buffer'):
|
||||
if sys.stdout.encoding and sys.stdout.encoding.lower() != 'utf-8':
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
||||
if sys.stderr and hasattr(sys.stderr, 'buffer'):
|
||||
if sys.stderr.encoding and sys.stderr.encoding.lower() != 'utf-8':
|
||||
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
||||
|
||||
import asyncio
|
||||
from typing import Optional, Type
|
||||
|
||||
Reference in New Issue
Block a user