Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions code/chapter6/AutoGenDemo/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def get_bitcoin_price():

# 添加刷新按钮
if st.button('刷新价格'):
st.experimental_rerun()
# 兼容新旧版本 Streamlit
if hasattr(st, 'rerun'):
st.rerun()
else:
st.experimental_rerun()

# 显示加载状态
with st.spinner('加载中...'):
Expand All @@ -36,4 +40,4 @@ def get_bitcoin_price():
if price_change_percentage is not None:
st.metric(label="24小时变化 (%)", value=f"{price_change_percentage:.2f}%")
else:
st.error("无法获取数据,请稍后重试。")
st.error("无法获取数据,请稍后重试。")