import streamlit as st # 標題 st.title("文件內容查看器") # 文件上傳 uploaded_file = st.file_uploader("請上傳文字或 Markdown 文件", type=["txt", "md"]) # 如果有文件被上傳 if uploaded_file is not None: # 讀取文件內容 content = uploaded_file.read().decode("utf-8") # 顯示文件內容 st.subheader(f"文件內容 ({uploaded_file.name})") st.write(content)