<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>时间 on 老张开工了</title>
    <link>/%E6%97%B6%E9%97%B4/</link>
    <description>Recent content in 时间 on 老张开工了</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    <lastBuildDate>Sat, 23 May 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="/%E6%97%B6%E9%97%B4/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>日期与时间处理</title>
      <link>/posts/2026/05/datetime/</link>
      <pubDate>Sat, 23 May 2026 00:00:00 +0000</pubDate>
      <guid>/posts/2026/05/datetime/</guid>
      <description>Python 中的日期和时间 日期和时间处理是编程中常见的需求——日志记录、数据统计、任务调度、业务逻辑计算，几乎每个项目都离不开它。Python 提供了多个内置模块来处理日期和时间，其中 datetime 是最核心、最常用的模块。&#xA;datetime 模块核心类 datetime 模块包含以下几个核心类：&#xA;类 说明 示例 date 日期（年、月、日） date(2026, 5, 21) time 时间（时、分、秒、微秒） time(14, 30, 0) datetime 日期+时间 datetime(2026, 5, 21, 14, 30) timedelta 时间差 timedelta(days=7) timezone 时区 timezone(timedelta(hours=8)) 创建日期和时间对象 from datetime import date, time, datetime, timedelta # 创建日期 d = date(2026, 5, 21) print(d) # 2026-05-21 print(d.year) # 2026 print(d.month) # 5 print(d.day) # 21 # 创建时间 t = time(14, 30, 15, 500000) print(t) # 14:30:15.</description>
    </item>
  </channel>
</rss>
