优化数据获取
This commit is contained in:
@@ -13,9 +13,23 @@ import io
|
||||
|
||||
warnings.filterwarnings('ignore')
|
||||
|
||||
# 设置标准输出编码为UTF-8(解决Windows终端显示问题)
|
||||
if sys.platform == 'win32':
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='ignore')
|
||||
# 设置标准输出编码为UTF-8(仅在命令行环境,避免streamlit冲突)
|
||||
def _setup_stdout_encoding():
|
||||
"""仅在命令行环境设置标准输出编码"""
|
||||
if sys.platform == 'win32' and not hasattr(sys.stdout, '_original_stream'):
|
||||
try:
|
||||
# 检测是否在streamlit环境中
|
||||
import streamlit
|
||||
# 在streamlit中不修改stdout
|
||||
return
|
||||
except ImportError:
|
||||
# 不在streamlit环境,可以安全修改
|
||||
try:
|
||||
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='ignore')
|
||||
except:
|
||||
pass
|
||||
|
||||
_setup_stdout_encoding()
|
||||
|
||||
|
||||
class MarketSentimentDataFetcher:
|
||||
|
||||
Reference in New Issue
Block a user