当前位置:首页>python>Python zoneinfo模块详细介绍

Python zoneinfo模块详细介绍

  • 2026-02-05 00:49:35
Python zoneinfo模块详细介绍

1. 创始时间与作者

  • 创始时间zoneinfo 首次在 Python 3.9 版本中作为标准库引入(发布于 2020 年 10 月 5 日),其背后标准在 PEP 615 中提出。

  • 核心开发者

    • Paul Ganssle:Python 核心开发者,也是 dateutil 库的维护者,是 PEP 615 的主要作者。

    • Python 核心开发团队:包括多个贡献者共同完成了实现。

    • 历史背景:基于 IANA(互联网号码分配局)时区数据库,该数据库最早由 Arthur David Olson 于 1986 年创立。

  • 项目定位:为 Python 标准库提供现代化的时区支持,替代传统的 pytz 库。

2. 官方资源

  • GitHub 地址(CPython 源码):https://github.com/python/cpython/tree/main/Lib/zoneinfo

  • Python 官方文档https://docs.python.org/3/library/zoneinfo.html

  • PEP 615 提案https://www.python.org/dev/peps/pep-0615/

  • IANA 时区数据库https://www.iana.org/time-zones

  • PyPI 向后兼容包https://pypi.org/project/backports.zoneinfo/

3. 核心功能

4. 应用场景

1. 基础时区处理

from datetime import datetimefrom zoneinfo import ZoneInfo# 创建时区感知的时间对象dt = datetime(202411120tzinfo=ZoneInfo("Asia/Shanghai"))print(f"上海时间: {dt}")# 上海时间: 2024-01-01 12:00:00+08:00# 转换为其他时区ny_time = dt.astimezone(ZoneInfo("America/New_York"))print(f"纽约时间: {ny_time}")# 纽约时间: 2024-01-01 00:00:00-05:00

2. 处理夏令时(DST)

from datetime import datetimetimedeltafrom zoneinfo import ZoneInfo# 创建跨越夏令时转换的时间tz = ZoneInfo("America/New_York")# 夏令时开始前(3月第二个星期日)before_dst = datetime(2024310159tzinfo=tz)print(f"夏令时开始前: {before_dst}")  # 2024-03-10 01:59:00-05:00# 1分钟后(跳过了2:00-2:59)after_dst = before_dst+timedelta(minutes=1)print(f"夏令时开始后: {after_dst}")   # 2024-03-10 03:00:00-04:00# 注意:1:59加1分钟直接变成3:00

3. 获取所有可用时区

from zoneinfo import available_timezones# 获取所有可用的时区名称zones = list(available_timezones())print(f"总共 {len(zones)} 个时区")# 按地区筛选asian_zones = [for in zones if z.startswith("Asia/")]print(f"亚洲时区示例: {asian_zones[:5]}")# ['Asia/Aden', 'Asia/Almaty', 'Asia/Amman', 'Asia/Anadyr', 'Asia/Aqtau']

4. Web应用中的时区处理

from datetime import datetimefrom zoneinfo import ZoneInfofrom flask import Flaskrequestjsonifyapp = Flask(__name__)@app.route('/api/events'methods=['POST'])def create_event():data = request.json# 用户提交的时间(假设带有时区信息)user_time_str = data['time']user_tz = ZoneInfo(data['timezone'])# 转换为UTC存储user_dt = datetime.fromisoformat(user_time_str)user_dt = user_dt.replace(tzinfo=user_tz)utc_dt = user_dt.astimezone(ZoneInfo("UTC"))# 存储UTC时间store_in_database({'event'data['event'],'utc_time'utc_dt,'user_timezone'data['timezone']    })return jsonify({"status""success""utc_time"utc_dt.isoformat()})# 查询时转换为用户时区@app.route('/api/events/<user_tz>')def get_events(user_tz):events = get_events_from_db()user_timezone = ZoneInfo(user_tz)result = []for event in events:# UTC时间转换为用户时区local_dt = event['utc_time'].astimezone(user_timezone)result.append({'event'event['name'],'local_time'local_dt.isoformat()        })return jsonify(result)

5. 批量时间转换

from datetime import datetimefrom zoneinfo import ZoneInfofrom concurrent.futures import ThreadPoolExecutordef convert_time_to_timezone(utc_dttarget_tz_name):"""将UTC时间转换为目标时区"""target_tz = ZoneInfo(target_tz_name)return utc_dt.astimezone(target_tz)# 批量处理多个时区转换utc_time = datetime.now(ZoneInfo("UTC"))target_timezones = ["America/New_York","Europe/London""Asia/Tokyo","Australia/Sydney","Asia/Shanghai"]# 并行转换with ThreadPoolExecutor() as executor:results = list(executor.map(lambda tzconvert_time_to_timezone(utc_timetz),target_timezones    ))for tz_namelocal_time in zip(target_timezonesresults):print(f"{tz_name}: {local_time}")

5. 底层逻辑与技术原理

核心架构

关键技术原理

1. TZif 文件格式解析

# TZif 文件结构(简化版)"""TZif 文件包含:1. 文件头:魔数 + 版本信息2. 时区转换时间点数组3. 转换类型数组(对应每个时间点的偏移规则)4. 时区缩写字符串5. 闰秒信息(可选)6. POSIX TZ 环境变量格式字符串zoneinfo 读取这些数据,构建时区规则表"""

2. 时区缓存机制

# zoneinfo 内部使用 LRU 缓存import functoolsfrom typing import Dictclass ZoneInfoCache:def __init__(selfmaxsizeint = 64):self._cacheDict[strZoneInfo] = {}self._maxsize = maxsizedef get_zoneinfo(selfkeystr->ZoneInfo:"""获取或创建 ZoneInfo 对象(带缓存)"""if key in self._cache:# 移动到最近使用zone = self._cache.pop(key)self._cache[key] = zonereturn zone# 创建新的 ZoneInfozone = self._create_zoneinfo(key)# 清理缓存(如果超出大小限制)if len(self._cache>self._maxsize:# 移除最久未使用的oldest_key = next(iter(self._cache))del self._cache[oldest_key]self._cache[key] = zonereturn zone

3. 时区规则查找算法

# 时区规则查找(简化示例)def find_timezone_transition(timestampfloattransitionslist->TimeZoneInfo:"""    根据时间戳查找适用的时区规则    参数:        timestamp: Unix 时间戳        transitions: 按时间排序的时区转换列表    返回:        当前时间戳对应的时区规则    """# 二分查找找到最后一个小于等于时间戳的转换点lowhigh = 0len(transitions-1result_idx = 0while low<high:mid = (low+high//2if transitions[mid].timestamp<timestamp:result_idx = midlow = mid+1else:high = mid-1return transitions[result_idx].zone_info

4. 夏令时处理逻辑

class DSTHandler:"""处理夏令时转换的逻辑"""@staticmethoddef is_dst_active(dtdatetimetz_rulesTimeZoneRules->bool:"""        判断指定时间是否处于夏令时        参数:            dt: 本地时间            tz_rules: 时区规则        返回:            bool: 是否处于夏令时        """# 1. 检查是否在夏令时时间段内year = dt.year# 获取该年的夏令时规则dst_startdst_end = tz_rules.get_dst_transitions(year)if dst_start is None or dst_end is None:return False# 2. 判断时间是否在夏令时区间内# 注意:需要处理模糊时间(时钟回拨的情况)is_in_dst = dst_start<dt<dst_end# 3. 处理转换点附近的时间if dt == dst_start:# 转换开始时刻,通常属于夏令时return Trueelif dt == dst_end:# 转换结束时刻,通常不属于夏令时return Falsereturn is_in_dst@staticmethoddef handle_ambiguous_time(dtdatetimetz_rulesTimeZoneRules->datetime:"""        处理模糊时间(夏令时结束时的重复小时)        返回:            datetime: 解析后的明确时间        """# 检查是否是模糊时间if tz_rules.is_ambiguous(dt):# 默认使用标准时间(非DST)# 可以通过参数控制使用哪个版本return dt.replace(fold=1)  # 使用第二个版本return dt

6. 安装与配置

Python 3.9+(内置)

# Python 3.9 及以上版本自带 zoneinfopython3 --version# 确认版本 >= 3.9# 直接使用即可from zoneinfo import ZoneInfo

Python 3.6-3.8(使用 backports)

# 安装 backports.zoneinfopip install backports.zoneinfo# 额外安装 tzdata(如果没有系统时区数据库)pip install tzdata# 使用方式from backports.zoneinfo import ZoneInfo

系统时区数据库配置

Linux/Unix 系统

# 检查系统是否有时区数据库ls /usr/share/zoneinfo/# 常见路径:# - /usr/share/zoneinfo/# - /usr/lib/zoneinfo/# - /etc/localtime(符号链接)# 安装时区数据库(如果需要)# Ubuntu/Debian:sudo apt-get install tzdata# CentOS/RHEL:sudo yum install tzdata

Windows 系统

# Windows 没有内置的时区数据库# 必须安装 tzdata 包pip install tzdata# 或者使用 backports.zoneinfo(自动包含 tzdata)pip install backports.zoneinfo

macOS 系统

# macOS 通常已安装时区数据库# 路径:/usr/share/zoneinfo/# 如果需要更新或安装brew install tzdata

环境配置选项

import osfrom zoneinfo import ZoneInfoavailable_timezones# 1. 设置时区数据搜索路径os.environ['TZDIR'] = '/custom/path/to/zoneinfo'# 2. 禁用系统时区数据(强制使用 tzdata)os.environ['PYTHONTZPATH'] = ''# 3. 自定义时区数据源class CustomZoneInfo(ZoneInfo):@classmethoddef from_file(clsfile_path):"""从自定义文件加载时区"""with open(file_path'rb'as f:return cls.from_file(f)

Docker 环境配置

# Dockerfile 示例FROM python:3.9-slim# 安装系统时区数据RUN apt-get update && apt-get install -y tzdata# 设置时区ENV TZ=Asia/ShanghaiRUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone# 安装应用依赖COPY requirements.txt .RUN pip install -r requirements.txt# 复制应用代码COPY . .CMD ["python", "app.py"]

测试安装是否成功

# test_zoneinfo.pyimport sysfrom zoneinfo import ZoneInfoavailable_timezonesprint(f"Python 版本: {sys.version}")print(f"zoneinfo 模块: {ZoneInfo.__module__}")# 测试基本功能try:tz = ZoneInfo("Asia/Shanghai")print(f"上海时区: {tz}")zones = list(available_timezones())print(f"可用时区数量: {len(zones)}")# 测试时区转换from datetime import datetimedt = datetime.now(tz)print(f"当前上海时间: {dt}")print("✅ zoneinfo 安装成功!")except Exception as e:print(f"❌ zoneinfo 安装失败: {e}")

版本兼容性矩阵

Python 版本安装方式备注
3.9+内置无需额外安装
3.6-3.8pip install backports.zoneinfo需要额外包
3.0-3.5不支持需使用 pytz 替代
无系统时区数据库pip install tzdata所有版本都需要

性能优化配置

# zoneinfo_config.pyimport zoneinfofrom zoneinfo import ZoneInfo# 1. 调整缓存大小(默认64)zoneinfo.reset_cache(maxsize=128)# 2. 预加载常用时区common_timezones = ["UTC","America/New_York","Europe/London""Asia/Shanghai","Asia/Tokyo"]# 预加载到缓存fort z_name in common_timezones:_ = ZoneInfo(tz_name)# 3. 监控缓存使用print(f"缓存大小: {zoneinfo._get_cache_size()}")

7. 性能优化

缓存策略对比

from datetime import datetimeimport timefrom zoneinfoimport ZoneInfoimport zoneinfodef benchmark_zoneinfo_creation():"""测试 ZoneInfo 对象创建性能"""zone_names = ["Asia/Shanghai""America/New_York""Europe/London"]# 第一次创建(未缓存)start = time.time()for name in zone_names*100:ZoneInfo(name)first_run = time.time() -start# 第二次创建(已缓存)start = time.time()for name in zone_names*100:ZoneInfo(name)second_run = time.time() -startprint(f"首次创建耗时: {first_run:.3f}s")print(f"缓存后创建耗时: {second_run:.3f}s")print(f"性能提升: {first_run/second_run:.1f}x")# 运行测试benchmark_zoneinfo_creation()

时区转换性能

from datetimeimport datetimetimedeltaimport timefrom zoneinfo import ZoneInfodef benchmark_timezone_conversion():"""测试时区转换性能"""# 创建测试数据utc_tz = ZoneInfo("UTC")target_tz = ZoneInfo("Asia/Shanghai")# 生成10000个时间点base_time = datetime(202411tzinfo=utc_tz)times = [base_time+timedelta(hours=ifor in range(10000)]# 测试转换性能start = time.time()converted = [t.astimezone(target_tzfor in times]elapsed = time.time() -startprint(f"转换 {len(times)} 个时间点耗时: {elapsed:.3f}s")print(f"平均每个转换: {elapsed/len(times)*1000:.2f}ms")# 运行测试benchmark_timezone_conversion()

8. 高级功能

1. 自定义时区规则

from datetime import datetimetimedeltafrom zoneinfo import ZoneInfoimport zoneinfo# 从自定义 TZif 文件创建时区custom_tz = ZoneInfo.from_file("/path/to/custom/timezone.tzif")# 创建简单自定义时区(固定偏移)class FixedOffsetZone(ZoneInfo):"""固定偏移时区"""def __init__(selfoffset_hoursintnamestr = "Custom"):self._offset = timedelta(hours=offset_hours)self._name = namedef utcoffset(selfdt):return self._offsetdef tzname(selfdt):return f"UTC{self._offset:+03d}:00"def dst(selfdt):return timedelta(0)def __repr__(self):return f"FixedOffsetZone({self._name}, offset={self._offset})"# 使用自定义时区custom = FixedOffsetZone(8"Beijing")dt = datetime(202411120tzinfo=custom)print(dt)  # 2024-01-01 12:00:00+08:00

2. 时区模糊时间处理

from datetime import datetimefrom zoneinfo import ZoneInfodef handle_ambiguous_times():"""处理模糊时间(夏令时结束时的重复小时)"""tz = ZoneInfo("America/New_York")# 2024-11-03 01:30 会出现两次(时钟回拨)# fold 参数决定使用哪个版本ambiguous_time = datetime(2024113130tzinfo=tz)# 第一个版本(夏令时)dt1 = ambiguous_time.replace(fold=0)print(f"第一个版本(DST): {dt1}")  # 2024-11-03 01:30:00-04:00# 第二个版本(标准时间)dt2 = ambiguous_time.replace(fold=1)print(f"第二个版本(标准): {dt2}")  # 2024-11-03 01:30:00-05:00# 检查是否是模糊时间print(f"是否是模糊时间: {dt1.utcoffset() != dt2.utcoffset()}")handle_ambiguous_times()

3. 时区序列化

import pickleimport jsonfrom datetime import datetimefrom zoneinfo import ZoneInfodef serialize_timezone():"""时区序列化示例"""# 创建时区感知的时间tz = ZoneInfo("Asia/Shanghai")dt = datetime(202411120tzinfo=tz)# 1. 使用 pickle 序列化serialized = pickle.dumps(dt)deserialized = pickle.loads(serialized)print(f"Pickle 反序列化: {deserialized}")  # 保持时区信息# 2. JSON 序列化(需要自定义处理)def datetime_encoder(obj):if isinstance(objdatetime):return {"datetime"obj.isoformat(),"timezone"str(obj.tzinfoif obj.tzinfo else None            }raise TypeError(f"Type {type(obj)} not serializable")# 转换为 JSONjson_str = json.dumps({"time"dt}, default=datetime_encoder)print(f"JSON 序列化: {json_str}")# JSON 反序列化def datetime_decoder(dct):if "datetime" in dct and "timezone" in dct:dt_str = dct["datetime"]tz_str = dct["timezone"]dt = datetime.fromisoformat(dt_str)if tz_str:dt = dt.replace(tzinfo=ZoneInfo(tz_str))return dtreturn dctdata = json.loads(json_strobject_hook=datetime_decoder)print(f"JSON 反序列化: {data['time']}")serialize_timezone()

4. 时区数据更新

import osimport subprocessfrom zoneinfo import ZoneInfoavailable_timezonesimport tzdata# 如果需要更新 tzdata 包def update_timezone_data():"""更新时区数据"""# 方法1:更新系统时区数据(Linux)if os.name == 'posix':try:# Ubuntu/Debiansubprocess.run(["sudo""apt-get""update""tzdata"], check=True)# 或# subprocess.run(["sudo", "dpkg-reconfigure", "tzdata"], check=True)except Exception as e:print(f"更新系统时区数据失败: {e}")# 方法2:更新 tzdata Python 包try:import pippip.main(['install''--upgrade''tzdata'])except Exception as e:print(f"更新 tzdata 包失败: {e}")# 方法3:手动下载 IANA 时区数据库# 从 https://www.iana.org/time-zones 下载最新版本# 替换系统或自定义路径中的时区文件# 清除 zoneinfo 缓存以使用新数据import zoneinfozoneinfo.reset_cache()print("时区数据更新完成")# 检查时区数据版本def check_timezone_version():"""检查当前时区数据版本"""tz = ZoneInfo("UTC")# 通过查看特定时区的历史变更来推断版本# 例如,检查最新的时区规则变更try:# 尝试访问最新添加的时区if "Asia/Yangon" in available_timezones():print("时区数据包含亚洲仰光时区(较新版本)")except:passupdate_timezone_data()check_timezone_version()

9. 与 pytz 对比

迁移指南:从 pytz 到 zoneinfo

# pytz 旧代码import pytzfrom datetime import datetime# pytz 使用方法utc = pytz.UTCeastern = pytz.timezone('US/Eastern')# 创建时间(需要 normalize)dt = eastern.localize(datetime(202411120))print(dt)# 转换时区(需要 normalize)ny_dt = dt.astimezone(pytz.timezone('America/New_York'))print(ny_dt)# -----------------------------------------------------# zoneinfo 新代码from datetime import datetimefrom zoneinfo import ZoneInfo# zoneinfo 使用方法(更简单)eastern = ZoneInfo('America/New_York')# 创建时间(直接指定)dt = datetime(202411120tzinfo=eastern)print(dt)# 转换时区(直接使用)ny_dt = dt.astimezone(ZoneInfo('America/New_York'))print(ny_dt)

功能对比表

特性pytzzoneinfo说明
Python 版本所有版本3.9+(或 backports)zoneinfo 需要较新版本
数据来源自带 Olson 数据库系统或 tzdata 包zoneinfo 更轻量
API 设计需要 localize()直接集成 datetimezoneinfo 更符合直觉
夏令时处理需要 normalize()自动处理zoneinfo 更简单
性能中等优秀(带缓存)zoneinfo 更快
内存占用较高较低zoneinfo 更轻量
维护状态维护中活跃开发zoneinfo 是未来方向

10. 企业级最佳实践

1. 时区处理中间件

# timezone_middleware.pyfrom datetime import datetimefrom zoneinfo import ZoneInfofrom typing import OptionalCallableimport functoolsclass TimezoneMiddleware:"""时区处理中间件"""def __init__(selfdefault_tzstr = "UTC"):self.default_tz = ZoneInfo(default_tz)def parse_datetime(selfdt_strstrtz_strOptional[str] = None->datetime:"""解析日期时间字符串,支持时区"""# 解析 ISO 格式字符串dt = datetime.fromisoformat(dt_str.replace('Z''+00:00'))# 应用时区if tz_str:tz = ZoneInfo(tz_str)if dt.tzinfo is None:dt = dt.replace(tzinfo=tz)else:dt = dt.astimezone(tz)elif dt.tzinfo is None:dt = dt.replace(tzinfo=self.default_tz)return dtdef format_datetime(selfdtdatetimeformat_strstr = "%Y-%m-%d %H:%M:%S %Z"->str:"""格式化日期时间"""return dt.strftime(format_str)def timezone_decorator(selffuncCallable):"""时区处理装饰器"""@functools.wraps(func)def wrapper(*args**kwargs):# 处理时区相关参数tz_param = kwargs.pop('timezone'None)if tz_param:tz = ZoneInfo(tz_param)kwargs['tzinfo'] = tzresult = func(*args**kwargs)# 处理返回的时间对象if isinstance(resultdatetimeand result.tzinfo is None:result = result.replace(tzinfo=self.default_tz)return resultreturn wrapper# 使用示例middleware = TimezoneMiddleware(default_tz="Asia/Shanghai")# 解析带时区的时间dt = middleware.parse_datetime("2024-01-01T12:00:00+08:00")print(f"解析结果: {dt}")# 格式化时间formatted = middleware.format_datetime(dt)print(f"格式化: {formatted}")

2. 数据库时区处理

# database_timezone.pyfrom datetime import datetimefrom zoneinfo import ZoneInfofrom sqlalchemy import ColumnDateTimeStringcreate_enginefrom sqlalchemy.ext.declarative import declarative_basefrom sqlalchemy.orm import sessionmakerimport pytz# 兼容旧代码Base = declarative_base()class Event(Base):__tablename__ = 'events'id = Column(Stringprimary_key=True)name = Column(String)# 存储 UTC 时间utc_time = Column(DateTime(timezone=True))# 记录原始时区original_timezone = Column(String)@classmethoddef create_with_timezone(clsnamestrlocal_dtdatetimetz_strstr):"""使用本地时间创建事件"""tz = ZoneInfo(tz_str)# 确保时间有时区信息if local_dt.tzinfo is None:local_dt = local_dt.replace(tzinfo=tz)# 转换为 UTC 存储utc_dt = local_dt.astimezone(ZoneInfo("UTC"))return cls(name=name,utc_time=utc_dt,original_timezone=tz_str        )def get_local_time(selftz_strOptional[str] = None->datetime:"""获取本地时间"""target_tz = ZoneInfo(tz_strif tz_str else ZoneInfo(self.original_timezone)return self.utc_time.astimezone(target_tz)# 使用示例engine = create_engine('sqlite:///:memory:')Base.metadata.create_all(engine)Session = sessionmaker(bind=engine)session = Session()# 创建事件event_time = datetime(202411120)event = Event.create_with_timezone("会议"event_time"Asia/Shanghai")session.add(event)session.commit()# 查询并转换为本地时间local_time = event.get_local_time("America/New_York")print(f"纽约时间: {local_time}")

3. 分布式系统时区同步

# distributed_timezone.pyimport uuidfrom datetime import datetimefrom typing import DictAnyfrom zoneinfo import ZoneInfoimport jsonclass DistributedTimeService:"""分布式系统时间服务"""def __init__(selfnode_idstrreference_tzstr = "UTC"):self.node_id = node_idself.reference_tz = ZoneInfo(reference_tz)self.clock_skew = {}  # 存储与其他节点的时钟偏差def generate_timestamp(selflocal_dtdatetime = None->Dict[strAny]:"""生成分布式时间戳"""if local_dt is None:local_dt = datetime.now(self.reference_tz)# 转换为参考时区(通常是UTC)reference_dt = local_dt.astimezone(self.reference_tz)timestamp = {"id"str(uuid.uuid4()),"node"self.node_id,"timestamp"reference_dt.isoformat(),"timezone"str(self.reference_tz),"local_time"local_dt.isoformat() if local_dt.tzinfo else None        }return timestampdef parse_distributed_timestamp(selfts_dataDict[strAny], target_tzstr = None->datetime:"""解析分布式时间戳"""# 解析参考时间reference_dt = datetime.fromisoformat(ts_data["timestamp"])# 如果有本地时间,优先使用if ts_data.get("local_time"):local_dt = datetime.fromisoformat(ts_data["local_time"])if target_tz:target_timezone = ZoneInfo(target_tz)local_dt = local_dt.astimezone(target_timezone)return local_dt# 否则使用参考时间转换if target_tz:target_timezone = ZoneInfo(target_tz)return reference_dt.astimezone(target_timezone)return reference_dtdef sync_clocks(selfother_timestampDict[strAny]) ->float:"""同步时钟,返回时钟偏差(秒)"""their_time = datetime.fromisoformat(other_timestamp["timestamp"])our_time = datetime.now(self.reference_tz)# 计算时间差(考虑网络延迟)time_diff = (their_time-our_time).total_seconds()# 记录该节点的时钟偏差self.clock_skew[other_timestamp["node"]] = time_diffreturn time_diff# 使用示例service1 = DistributedTimeService("node1""UTC")service2 = DistributedTimeService("node2""Asia/Shanghai")# 生成时间戳ts1 = service1.generate_timestamp()print(f"节点1时间戳: {json.dumps(ts1, indent=2)}")# 同步时钟skew = service2.sync_clocks(ts1)print(f"时钟偏差: {skew}秒")# 解析时间戳parsed = service2.parse_distributed_timestamp(ts1"America/New_York")print(f"解析为纽约时间: {parsed}")

11. 总结

zoneinfo 是 Python 时区处理的现代解决方案,核心价值在于:

主要优势

  1. 标准库集成:Python 3.9+ 内置,无需额外依赖

  2. API 简洁:直接与 datetime 集成,符合 Python 哲学

  3. 性能优秀:智能缓存机制,高效处理时区转换

  4. 数据准确:基于权威的 IANA 时区数据库

  5. 跨平台:支持系统时区数据库和备用 tzdata 包

技术特点

  • 智能缓存:LRU 缓存机制减少重复加载

  • 灵活数据源:系统数据库 → tzdata 包 → 自定义文件

  • 完整 DST 支持:自动处理夏令时和模糊时间

  • 序列化友好:完美支持 pickle 序列化

适用场景

  1. Web 应用:用户时区转换、时间显示

  2. 企业系统:跨国业务时间协调

  3. 数据分析:时间序列数据的时区标准化

  4. 物联网:分布式设备时间同步

  5. 金融服务:跨时区交易时间处理

迁移建议

  • 新项目:直接使用 zoneinfo(Python 3.9+)

  • 旧项目:逐步迁移,优先在新增代码中使用

  • 兼容性:使用 backports.zoneinfo 支持 Python 3.6-3.8

安装指南

# Python 3.9+无需安装,直接使用# Python 3.6-3.8pip install backports.zoneinfo# 无系统时区数据库pip install tzdata

zoneinfo 代表了 Python 时区处理的未来方向,其简洁的 API 和优秀的性能使其成为替代 pytz 的首选方案。随着 Python 3.9+ 的普及,zoneinfo 将成为处理时区问题的标准方式。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-07 15:15:25 HTTP/2.0 GET : https://f.mffb.com.cn/a/472143.html
  2. 运行时间 : 0.509954s [ 吞吐率:1.96req/s ] 内存消耗:4,698.34kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=f4e7aed6ab1d97e9262f50e8464d868e
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000573s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000656s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.003491s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.015214s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000620s ]
  6. SELECT * FROM `set` [ RunTime:0.010519s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000628s ]
  8. SELECT * FROM `article` WHERE `id` = 472143 LIMIT 1 [ RunTime:0.128966s ]
  9. UPDATE `article` SET `lasttime` = 1770448525 WHERE `id` = 472143 [ RunTime:0.037335s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.001866s ]
  11. SELECT * FROM `article` WHERE `id` < 472143 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001480s ]
  12. SELECT * FROM `article` WHERE `id` > 472143 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.002128s ]
  13. SELECT * FROM `article` WHERE `id` < 472143 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.010138s ]
  14. SELECT * FROM `article` WHERE `id` < 472143 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.091413s ]
  15. SELECT * FROM `article` WHERE `id` < 472143 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.124135s ]
0.513188s