ARTICLE DETAIL

建站实战干货

来自一线的建站与推广经验沉淀,每一条都经过真实交付验证。

如何利用 streamlit 產生多個頁面

2026/9/19 11:31:46 拓冰建站 浏览量
如何利用 streamlit 產生多個頁面

1.主程式如下 ,app.py

import app1
import app2
import streamlit as st
PAGES = {"範例一": app1,"範例二": app2}
st.sidebar.title('Navigation')
selection = st.sidebar.radio("Go to", list(PAGES.keys()))
page = PAGES[selection]
page.app()

2.產生另外兩個 py檔案 app1, app2

import streamlit as st
def app():st.title('APP1')st.write('Welcome to app1')

import streamlit as st
def app():
st.title(‘APP2’)
st.write(‘Welcome to app2’)

3.呈現畫面如下
在这里插入图片描述