Update app.py
Browse files
app.py
CHANGED
|
@@ -23,6 +23,13 @@ def process_number(number):
|
|
| 23 |
def main():
|
| 24 |
st.title("幸運數字查詢系統")
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
# 檔案上傳部分
|
| 27 |
uploaded_file = st.file_uploader("請上傳CSV檔案", type=['csv'])
|
| 28 |
|
|
@@ -64,11 +71,20 @@ def main():
|
|
| 64 |
progress_bar.progress(progress)
|
| 65 |
status_text.text(f"正在處理: {index + 1}/{total_rows}")
|
| 66 |
|
| 67 |
-
#
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
# 顯示結果
|
| 74 |
st.subheader("完整結果")
|
|
|
|
| 23 |
def main():
|
| 24 |
st.title("幸運數字查詢系統")
|
| 25 |
|
| 26 |
+
# 讓使用者選擇幸運數字的位數
|
| 27 |
+
selected_digits = st.selectbox(
|
| 28 |
+
"請選擇幸運數字的位數",
|
| 29 |
+
options=range(4, 11), # 4 到 10 位
|
| 30 |
+
index=3 # 預設選 7 位
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
# 檔案上傳部分
|
| 34 |
uploaded_file = st.file_uploader("請上傳CSV檔案", type=['csv'])
|
| 35 |
|
|
|
|
| 71 |
progress_bar.progress(progress)
|
| 72 |
status_text.text(f"正在處理: {index + 1}/{total_rows}")
|
| 73 |
|
| 74 |
+
# 獲取幸運數字並檢查位數
|
| 75 |
+
original_number = str(row['幸運號碼'])
|
| 76 |
+
number_length = len(original_number)
|
| 77 |
+
|
| 78 |
+
if number_length > selected_digits:
|
| 79 |
+
# 超過指定位數,標記為不符規定
|
| 80 |
+
df.at[index, '幸運號碼'] = original_number # 保留原始輸入
|
| 81 |
+
df.at[index, '查詢結果'] = "數字不符規定"
|
| 82 |
+
else:
|
| 83 |
+
# 小於或等於指定位數,補零後查詢
|
| 84 |
+
lucky_number = original_number.zfill(selected_digits)
|
| 85 |
+
result = process_number(lucky_number)
|
| 86 |
+
df.at[index, '幸運號碼'] = lucky_number # 更新為補零後的數字
|
| 87 |
+
df.at[index, '查詢結果'] = result
|
| 88 |
|
| 89 |
# 顯示結果
|
| 90 |
st.subheader("完整結果")
|