fork download
  1. # 2026年 2月休假表 - 文字呈現版 (適合 Ideone)
  2.  
  3. def print_schedule():
  4. # 定義姓名與休假日期
  5. leaves = {
  6. "秀蘭": [4,7,9,11,13,16,18,19,21,22,25,26,28],
  7. "子硯": [3,6,7,10,14,15,16,17,20,21,24,28],
  8. "家和": [1,4,5,6,7,9,10,15,16,17,18,19,23,27],
  9. "宇翔": [1,2,3,8,9,14,16,17,18,19,20,26,27,28]
  10. }
  11.  
  12. # 2026/2/1 是星期日
  13. weekdays = ["日", "一", "二", "三", "四", "五", "六"]
  14. dates = [f"{i}({weekdays[i % 7]})" for i in range(1, 29)]
  15.  
  16. # 為了方便閱讀,拆分成兩段呈現 (1-14日, 15-28日)
  17. segments = [(0, 14), (14, 28)]
  18.  
  19. for start, end in segments:
  20. current_dates = dates[start:end]
  21. print("-" * 100)
  22. # 標題行
  23. header = f"{'姓名 / 日期':<10}" + "".join([f"{d:>7}" for d in current_dates])
  24. print(header)
  25. print("-" * 100)
  26.  
  27. # 每位員工行
  28. for name, leave_days in leaves.items():
  29. row = f"{name:<12}"
  30. for day_idx in range(start + 1, end + 1):
  31. mark = "V" if day_idx in leave_days else "-"
  32. row += f"{mark:>7}"
  33. print(row)
  34.  
  35. # 統計行
  36. count_row = f"{'共休人數':<10}"
  37. for day_idx in range(start + 1, end + 1):
  38. count = sum(1 for person_days in leaves.values() if day_idx in person_days)
  39. # 標註 3 人以上同時休假
  40. display_count = f"*{count}*" if count >= 3 else str(count)
  41. count_row += f"{display_count:>7}"
  42. print(count_row)
  43. print("\n")
  44.  
  45. if __name__ == "__main__":
  46. print_schedule()
  47.  
Success #stdin #stdout 0.03s 9408KB
stdin
Standard input is empty
stdout
----------------------------------------------------------------------------------------------------
姓名 / 日期      1(一)   2(二)   3(三)   4(四)   5(五)   6(六)   7(日)   8(一)   9(二)  10(三)  11(四)  12(五)  13(六)  14(日)
----------------------------------------------------------------------------------------------------
秀蘭                -      -      -      V      -      -      V      -      V      -      V      -      V      -
子硯                -      -      V      -      -      V      V      -      -      V      -      -      -      V
家和                V      -      -      V      V      V      V      -      V      V      -      -      -      -
宇翔                V      V      V      -      -      -      -      V      V      -      -      -      -      V
共休人數            2      1      2      2      1      2    *3*      1    *3*      2      1      0      1      2


----------------------------------------------------------------------------------------------------
姓名 / 日期     15(一)  16(二)  17(三)  18(四)  19(五)  20(六)  21(日)  22(一)  23(二)  24(三)  25(四)  26(五)  27(六)  28(日)
----------------------------------------------------------------------------------------------------
秀蘭                -      V      -      V      V      -      V      V      -      -      V      V      -      V
子硯                V      V      V      -      -      V      V      -      -      V      -      -      -      V
家和                V      V      V      V      V      -      -      -      V      -      -      -      V      -
宇翔                -      V      V      V      V      V      -      -      -      -      -      V      V      V
共休人數            2    *4*    *3*    *3*    *3*      2      2      1      1      1      1      2      2    *3*