全部 新建

user:thomas 由使用者建立的 Gists

title:mygist Gists 的標題

filename:myfile.txt Gists 的檔案名稱

extension:yml Gists 的副檔名

language:go Gists 的程式語言

topic:homelab gists with given topic

登錄


全部 新建 登錄

All gists matching topic simple-script

倒序排序 創建
順序排序 創建
倒序排序 更新
順序排序 更新

timmy / 📆 閏年還是平年?一行 Python 判斷超直覺!

0 喜歡
0 分支
1 檔案
最後活躍 8 months ago
用最簡單的邏輯搞懂閏年判斷:被 4 整除但不能被 100 整除,或被 400 整除就對了 ✅
beginner-friendly date-utils datetime leap-year python simple-script
1 def is_leap_year(year):
2 return (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0)
3
4
5 # 調用 is_leap_year 函數來判斷特定年份是否為閏年
6 year = 2024 # 請更改為您想要檢查的年份
7 if is_leap_year(year):
8 print(f"{year} 年是閏年")
9 else:
10 print(f"{year} 年不是閏年")
上一頁 下一頁

由 Opengist 提供支持 ⋅ Load: 20ms⋅

繁體中文
Čeština Deutsch English Español Français Magyar Italiano 日本語 Polski Português Русский Türkçe Українська 中文 繁體中文