Todos Nuevo

user:thomas gists creados por el usuario

title:mygist gists con el título indicado

filename:myfile.txt gists que contienen archivos con el nombre indicado

extension:yml gists que contienen archivos con la extensión indicada

language:go gists que contienen archivos con el lenguaje indicado

topic:homelab gists with given topic

Iniciar sesión


Todos Nuevo Iniciar sesión

All gists matching topic simple-script

Recientemente creado
Menos reciente creado
Recientemente actualizado
Menos reciente actualizado

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

0 gustos
0 bifurcaciones
1 archivos
Última actividad 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} 年不是閏年")
Siguiente Anterior

Desarrollado por Opengist ⋅ Load: 19ms⋅

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