显示异常。
通过以下方式访问应用时localhost,在异常的右下角,Streamlit 会显示指向 Google 和 ChatGPT 的链接,这些链接已预填充异常消息的内容。
函数签名[source] | |
---|---|
st.exception(exception, width="stretch") | |
参数 | |
exception (Exception) | 要显示的异常。 |
width (int or "stretch") | 异常的期望宽度,以像素表示。如果这是"stretch"(默认),Streamlit 会将异常的宽度设置为与其父容器的宽度相匹配。否则,这必须是一个整数。如果指定的宽度大于父容器的宽度,Streamlit 会将异常的宽度设置为与其父容器的宽度相匹配。 |
示例
import streamlit as st e = RuntimeError("This is an exception of type RuntimeError") st.exception(e)
还有其他问题?
我们的 论坛 提供大量有用的信息和 Streamlit 专家资源。