【求助】streamlit页面更新方法 st.experimental_rerun() 报错误 #227

Open
opened 2024-10-18 12:26:52 +08:00 by PeterWang · 1 comment

我做了一个文件上传/下载功能(方便后面Rag里面使用),
文件删除时,调用了st.experimental_rerun() ,报错。
代码
col1, col2, col3, col4 = st.columns([3, 1, 1, 5])
with col1:
st.write(file_name)
with col2:
download_key = f"download_{file_name}"
download_button = st.download_button(
label="Download",
data=open(file_path, "rb"),
file_name=file_name,
mime=file_type,
key=download_key
)
with col3:
# 删除按钮
delete_key = f"delete_{file_name}"
if st.button("Delete", key=file_name):
if delete_file(file_name):
st.success(f"文件 '{file_name}' 已成功删除。")
st.experimental_rerun()
else:
st.error(f"删除文件 '{file_name}' 失败。")

错误:
7f99a1db590349fe8d6a25d9a287603

我做了一个文件上传/下载功能(方便后面Rag里面使用), 文件删除时,调用了st.experimental_rerun() ,报错。 代码 col1, col2, col3, col4 = st.columns([3, 1, 1, 5]) with col1: st.write(file_name) with col2: download_key = f"download_{file_name}" download_button = st.download_button( label="Download", data=open(file_path, "rb"), file_name=file_name, mime=file_type, key=download_key ) with col3: # 删除按钮 delete_key = f"delete_{file_name}" if st.button("Delete", key=file_name): if delete_file(file_name): st.success(f"文件 '{file_name}' 已成功删除。") st.experimental_rerun() else: st.error(f"删除文件 '{file_name}' 失败。") 错误: <img width="1081" alt="7f99a1db590349fe8d6a25d9a287603" src="/attachments/19a82b10-a0f7-4a15-9aa8-5b82802c44e8">

st.rerun() 用这个试试

st.rerun() 用这个试试
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: HswOAuth/llm_course#227
No description provided.