init. 初始化项目,并初步完成前端模板样式
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
def get_now_strftime_format():
|
||||
"""
|
||||
返回当前时间的格式化字符串:'2026年3月25日 星期三'
|
||||
特点:
|
||||
1. 自动去除月、日的前导零 (如 3月 而非 03月)
|
||||
2. 强制输出 '星期X' 格式 (避免系统差异导致输出 '周X')
|
||||
"""
|
||||
now = datetime.now()
|
||||
|
||||
# 星期映射列表 (weekday(): 0=周一, ..., 6=周日)
|
||||
weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
|
||||
|
||||
# 使用 strftime 获取年份,直接属性获取月日(自动无前导零),列表获取星期
|
||||
# %Y: 四位年份
|
||||
year_str = now.strftime("%Y")
|
||||
month_val = now.month # 整数,自动无前置0
|
||||
day_val = now.day # 整数,自动无前置0
|
||||
weekday_str = weekdays[now.weekday()]
|
||||
|
||||
return f"{year_str}年{month_val}月{day_val}日 {weekday_str}"
|
||||
Reference in New Issue
Block a user