Search code examples
pythoncsvstreamlitsave-as

Is it possible to save a text after clicking a button on streamlit?


I have

b0 = st.button("Hi There", key=0)
        if b0:
            st.write("gratitude word")

is it possible to save the output of clicking b0? so basically saving the "gratitude word" as CSV, named something like file_one.csv


Solution

  • b0 = st.button("Hi There", key=0)
        if b0:
            st.write("gratitude word")
            with open("file.csv", "w") as f:
                print("xxx", file=f)
    

    does the job.