데이터 분석/[Python] Troubleshooting
AttributeError: st.session_state has no attribute “key”. Did you forget to initialize it?
INCHELIN
2023. 11. 14. 15:41
728x90
import streamlit as st
if 'key' not in st.session_state:
st.session_state['key'] = 'value'
# Update session state
st.session_state['key'] = 'value4'
# Read session state
st.write(st.session_state['key'])
해당 코드를 .py 로 저장하기(파일명 예시 : streamlit_app.py)
터미널에서 streamlit 실행하기
streamlit run streamlit_app.py
728x90