Last active 10 months ago
此程式使用 Streamlit 讀取、編輯並儲存員工資料至 YAML 檔案,提供直覺化 UI 介面,並支援欄位過濾與年齡篩選,適用於企業資料管理。
1 employees:
2 - Age: 34
3 City: New York
4 Name: Alice
5 Occupation: Engineer
6 Salary: 70000
7 - Age: 27
8 City: Los Angeles
9 Name: Bob
10 Occupation: Doctor

timmy / 使用 Streamlit 建立 YAML 編輯器

0 likes
0 forks
1 files
Last active 10 months ago
此程式使用 Streamlit 讓使用者讀取、編輯並儲存 YAML 文件,透過 pandas 轉換為表格格式,適用於設定檔管理與資料編輯工具。
1 from io import StringIO
2
3 import pandas as pd
4 import streamlit as st
5 import yaml
6
7
8 # 定義 YamlHandler 類
9 class YamlHandler:
10 def __init__(self, file_path):
Last active 10 months ago
此程式使用 Streamlit 讀取、編輯並存儲 YAML 設定檔,透過 pandas 轉換為表格格式,提供直覺化 UI 介面,適用於設定管理與資料修改。
1 age: 30
2 is_active: true
3 name: John Doe
Last active 10 months ago
這是一個使用 Streamlit 構建的訂餐系統,包含訂購人選擇、餐廳菜單顯示、主餐及加點品項的選擇與數量輸入,並計算和顯示訂單詳情與總價。
1 from datetime import date
2
3 import streamlit as st
4
5 # 定義 Customer 類別
6 class Customer:
7 def __init__(self, name, email, preferences):
8 self.name = name
9 self.email = email
10 self.preferences = preferences
Last active 10 months ago
這段程式碼使用 Streamlit 和 streamlit-authenticator 來 管理使用者登入,透過 YAML 設定檔 儲存使用者憑證與 Cookie 配置,並提供 登入、登出 和 使用者驗證 功能。
1 cookie:
2 expiry_days: 30
3 key: some_signature_key
4 name: my_auth_cookie
5 credentials:
6 usernames:
7 jsmith:
8 email: jsmith@gmail.com
9 failed_login_attempts: 0 # Will be managed automatically
10 logged_in: False # Will be managed automatically
Last active 10 months ago
這段 Python 程式碼利用 funcy 模組的裝飾器來 檢查目前作業系統,從而限制某些函式僅在特定平台上執行。具體來說,need_mac、need_linux、need_windows 與 need_unix 分別用來檢查是否在 macOS、Linux、Windows 或 Unix(macOS 或 Linux)系統上執行;函式 foo() 被 @need_unix 裝飾,僅允許在 Unix 系統上執行,而函式 bar() 則僅允許在 Windows 系統上執行。主程式透過 try-except 捕捉例外,若目前作業系統不符合要求,則輸出相應錯誤訊息。這樣的設計有助於確保平台專屬功能在正確的環境中執行,避免跨平台錯誤。
1 import platform
2 from funcy import decorator
3
4 @decorator
5 def need_mac(call):
6 """檢查系統是否為 macOS,若不是則拋出異常。"""
7 if platform.system() != "Darwin":
8 raise Exception("This functionality is only supported in macOS")
9 return call()