Preciso rodar um trecho de um codigo, somente uma vez, e seria logo na primeira rodada do Streamlit
Olá @tevin ! Benvindo ao fórum
A maneira mais fácil de rodar um código só uma vez é usando o st.cache
:
@st.cache
def run_this_only_once():
# Do stuff in here!
a = 42
run_this_only_once()
And now in English…
Here’s a summary of this thread in English so other people can read
The question was: How can I run a piece of code only once, when Streamlit first starts?
And my response: The simplest way is to use st.cache. See the code above.
Abraço!
2 Likes