简体   繁体   English

如何将 streamlit 输出下载为 html 文件

[英]How to download streamlit output as html file

I generated an interactive output in Streamlit;我在 Streamlit 中生成了交互式输出; I need to download the output as an HTML file in local.我需要将输出下载为本地的 HTML 文件。 By clicking the button, the download has to be initiated.通过单击按钮,必须启动下载。 Can anyone please help me on this?谁能帮我解决这个问题?

You can read document , there exists an example about .csv file.您可以阅读文档,这里有一个关于.csv文件的示例。

Here I can give an example about html:这里我可以举一个关于html的例子:

import pandas as pd
import streamlit as st


df=pd.read_csv("test.csv")

@st.cache
def convert_df(df):
    return df.to_html().encode('utf-8')

html = convert_df(df)

st.download_button(
    "Press to Download",
    html,
    "test.html"
)

在此处输入图像描述

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM