Files
hustoj/web/python-docs/library/calendar.html
2025-03-09 17:10:56 +08:00

619 lines
53 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<title>calendar --- 日历相关函数 &#8212; Python 3.8.20 文档</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<script src="../_static/translations.js"></script>
<script src="../_static/sidebar.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="在 Python 3.8.20 文档 中搜索"
href="../_static/opensearch.xml"/>
<link rel="author" title="关于这些文档" href="../about.html" />
<link rel="index" title="索引" href="../genindex.html" />
<link rel="search" title="搜索" href="../search.html" />
<link rel="copyright" title="版权所有" href="../copyright.html" />
<link rel="next" title="collections --- 容器数据类型" href="collections.html" />
<link rel="prev" title="datetime --- 基本日期和时间类型" href="datetime.html" />
<link rel="canonical" href="https://docs.python.org/3/library/calendar.html" />
<style>
@media only screen {
table.full-width-table {
width: 100%;
}
}
</style>
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
<script type="text/javascript" src="../_static/copybutton.js"></script>
<script type="text/javascript" src="../_static/menu.js"></script>
</head>
<body>
<div class="mobile-nav">
<input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
<label for="menuToggler" class="toggler__label">
<span></span>
</label>
<nav class="nav-content" role="navigation">
<a href="https://www.python.org/" class="nav-logo">
<img src="../_static/py.svg" alt="Logo"/>
</a>
<div class="version_switcher_placeholder"></div>
<form role="search" class="search" action="../search.html" method="get">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
<path fill-rule="nonzero"
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
</svg>
<input type="text" name="q" aria-label="快速搜索"/>
<input type="submit" value="转向"/>
</form>
</nav>
<div class="menu-wrapper">
<nav class="menu" role="navigation" aria-label="main navigation">
<div class="language_switcher_placeholder"></div>
<h4>上一个主题</h4>
<p class="topless"><a href="datetime.html"
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code> --- 基本日期和时间类型</a></p>
<h4>下一个主题</h4>
<p class="topless"><a href="collections.html"
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code> --- 容器数据类型</a></p>
<div role="note" aria-label="source link">
<h3>本页</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">报告 Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/calendar.rst"
rel="nofollow">显示源代码
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<div id="outdated-warning" style="padding: .5em; text-align: center; background-color: #FFBABA; color: #6A0E0E;">
这个文档所针对的是一个已不再受支持的 Python 旧版本。
你应当升级版本,并阅读
<a href="/3/library/calendar.html"> Python 当前稳定版本的文档</a>.
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>导航</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="总目录"
accesskey="I">索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python 模块索引"
>模块</a> |</li>
<li class="right" >
<a href="collections.html" title="collections --- 容器数据类型"
accesskey="N">下一页</a> |</li>
<li class="right" >
<a href="datetime.html" title="datetime --- 基本日期和时间类型"
accesskey="P">上一页</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.8.20 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="datatypes.html" accesskey="U">数据类型</a> &#187;</li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
<input type="submit" value="转向" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
|
</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="module-calendar">
<span id="calendar-general-calendar-related-functions"></span><h1><a class="reference internal" href="#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a> --- 日历相关函数<a class="headerlink" href="#module-calendar" title="永久链接至标题"></a></h1>
<p><strong>源代码:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.8/Lib/calendar.py">Lib/calendar.py</a></p>
<hr class="docutils" />
<p>这个模块让你可以输出像 Unix <strong class="program">cal</strong> 那样的日历,它还提供了其它与日历相关的实用函数。 默认情况下,这些日历把星期一作为一周的第一天,星期天作为一周的最后一天(这是欧洲惯例)。可以使用 <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-func docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> 方法设置一周的第一天为星期天 (6) 或者其它任意一天。函数全部接收整数类型的参数用来指定日期。其它相关功能参见 <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a><a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> 模块。</p>
<p>在这个模块中定义的函数和类都基于一个理想化的日历——向过去和未来两个方向无限扩展的现行公历。这与 Dershowitz 和 Reingold 的书“历法计算”中所有计算的基本日历 &quot;proleptic Gregorian&quot; 历的定义相符。0 和负数年份按照 ISO 8601 标准解释0 年指公元前 1 年,-1 年指公元前 2 年,依此类推。</p>
<dl class="class">
<dt id="calendar.Calendar">
<em class="property">class </em><code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">Calendar</code><span class="sig-paren">(</span><em class="sig-param">firstweekday=0</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar" title="永久链接至目标"></a></dt>
<dd><p>创建一个 <a class="reference internal" href="#calendar.Calendar" title="calendar.Calendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code></a> 对象。 <em>firstweekday</em> 是一个整数,用于指定一周的第一天。 <code class="docutils literal notranslate"><span class="pre">0</span></code> 是星期一(默认值),<code class="docutils literal notranslate"><span class="pre">6</span></code> 是星期天。</p>
<p><a class="reference internal" href="#calendar.Calendar" title="calendar.Calendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code></a> 对象提供了一些可用于对日历数据进行格式化的准备的方法。这个类本身不执行任何格式化操作。 这部分任务应由子类来完成。</p>
<p><a class="reference internal" href="#calendar.Calendar" title="calendar.Calendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">Calendar</span></code></a> 实例有下列方法:</p>
<dl class="method">
<dt id="calendar.Calendar.iterweekdays">
<code class="sig-name descname">iterweekdays</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.iterweekdays" title="永久链接至目标"></a></dt>
<dd><p>返回一个迭代器,迭代器的内容为一周里每天的星期值。迭代器的第一个值与 <a class="reference internal" href="#calendar.firstweekday" title="calendar.firstweekday"><code class="xref py py-attr docutils literal notranslate"><span class="pre">firstweekday</span></code></a> 属性的值一致。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.itermonthdates">
<code class="sig-name descname">itermonthdates</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdates" title="永久链接至目标"></a></dt>
<dd><p><em>year</em><em>month</em> 月 (1-12) 返回一个迭代器。这个迭代器返回当月的所有日期(使用 <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> 对象),日期包含了本月头尾用于组成完整一周的日期。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.itermonthdays">
<code class="sig-name descname">itermonthdays</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays" title="永久链接至目标"></a></dt>
<dd><p><em>year</em><em>month</em> 月返回一个与 <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a> 类似的迭代器,但不会受 <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> 范围的限制。返回的为每一天的日期相对于当月 1 日过去的天数。对于不在当月的日期,返回数字 <code class="docutils literal notranslate"><span class="pre">0</span></code></p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.itermonthdays2">
<code class="sig-name descname">itermonthdays2</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays2" title="永久链接至目标"></a></dt>
<dd><p><em>year</em><em>month</em> 月返回一个与 <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a> 类似的迭代器,但不会受 <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> 范围的限制。迭代器中的每一个元素为由日数和代表星期几的数字组成的元组。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.itermonthdays3">
<code class="sig-name descname">itermonthdays3</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays3" title="永久链接至目标"></a></dt>
<dd><p><em>year</em><em>month</em> 月返回一个与 <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a> 类似的迭代器,但不会受 <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> 范围的限制。迭代器的元素为一个由年、月、日组成的元组。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.itermonthdays4">
<code class="sig-name descname">itermonthdays4</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.itermonthdays4" title="永久链接至目标"></a></dt>
<dd><p><em>year</em><em>month</em> 月返回一个与 <a class="reference internal" href="#calendar.Calendar.itermonthdates" title="calendar.Calendar.itermonthdates"><code class="xref py py-meth docutils literal notranslate"><span class="pre">itermonthdates()</span></code></a> 类似的迭代器,但不会受 <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> 范围的限制。迭代器的元素为一个由年、月、日和代表星期几的数字组成的元组。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.monthdatescalendar">
<code class="sig-name descname">monthdatescalendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdatescalendar" title="永久链接至目标"></a></dt>
<dd><p>返回 <em>year</em><em>month</em> 月的周组成的列表。列表中的每一个周是由七个 <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> 对象组成的列表。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.monthdays2calendar">
<code class="sig-name descname">monthdays2calendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdays2calendar" title="永久链接至目标"></a></dt>
<dd><p>返回 <em>year</em><em>month</em> 月的周组成的列表。列表中的每一个周是七个由日数和代表星期几的数字组成的元组的列表。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.monthdayscalendar">
<code class="sig-name descname">monthdayscalendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.monthdayscalendar" title="永久链接至目标"></a></dt>
<dd><p>返回 <em>year</em><em>month</em> 月的周组成的列表。列表中的每一个周是由七个日数组成的列表。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.yeardatescalendar">
<code class="sig-name descname">yeardatescalendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">width=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardatescalendar" title="永久链接至目标"></a></dt>
<dd><p>返回可以用来格式化的指定年月的数据。返回的值是一个列表,列表是月份组成的行。每一行包含了最多 <em>width</em> 个月(默认为3)。每个月包含了4到6周每周包含1--7天。每一天使用 <a class="reference internal" href="datetime.html#datetime.date" title="datetime.date"><code class="xref py py-class docutils literal notranslate"><span class="pre">datetime.date</span></code></a> 对象。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.yeardays2calendar">
<code class="sig-name descname">yeardays2calendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">width=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardays2calendar" title="永久链接至目标"></a></dt>
<dd><p>返回可以用来模式化的指定年月的数据(与 <a class="reference internal" href="#calendar.Calendar.yeardatescalendar" title="calendar.Calendar.yeardatescalendar"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yeardatescalendar()</span></code></a> 类似)。周列表的元素是由表示日期的数字和表示星期几的数字组成的元组。不在这个月的日子为0。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.Calendar.yeardayscalendar">
<code class="sig-name descname">yeardayscalendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">width=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.Calendar.yeardayscalendar" title="永久链接至目标"></a></dt>
<dd><p>返回可以用来模式化的指定年月的数据(与 <a class="reference internal" href="#calendar.Calendar.yeardatescalendar" title="calendar.Calendar.yeardatescalendar"><code class="xref py py-meth docutils literal notranslate"><span class="pre">yeardatescalendar()</span></code></a> 类似)。周列表的元素是表示日期的数字。不在这个月的日子为0。</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="calendar.TextCalendar">
<em class="property">class </em><code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">TextCalendar</code><span class="sig-paren">(</span><em class="sig-param">firstweekday=0</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar" title="永久链接至目标"></a></dt>
<dd><p>可以使用这个类生成纯文本日历。</p>
<p><a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> 实例有以下方法:</p>
<dl class="method">
<dt id="calendar.TextCalendar.formatmonth">
<code class="sig-name descname">formatmonth</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">themonth</em>, <em class="sig-param">w=0</em>, <em class="sig-param">l=0</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatmonth" title="永久链接至目标"></a></dt>
<dd><p>返回指定月的用多行字符串表示的月历。<em>w</em> 为日期列的宽度,日期列居中打印。<em>l</em> 指定了周与周之间的行距。返回的日历还依赖于构造器或者 <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> 方法指定的每周的第一天是哪一天。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.TextCalendar.prmonth">
<code class="sig-name descname">prmonth</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">themonth</em>, <em class="sig-param">w=0</em>, <em class="sig-param">l=0</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.prmonth" title="永久链接至目标"></a></dt>
<dd><p>调用 <a class="reference internal" href="#calendar.TextCalendar.formatmonth" title="calendar.TextCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a> 方法并打印返回的月历。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.TextCalendar.formatyear">
<code class="sig-name descname">formatyear</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">w=2</em>, <em class="sig-param">l=1</em>, <em class="sig-param">c=6</em>, <em class="sig-param">m=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.formatyear" title="永久链接至目标"></a></dt>
<dd><p>返回指定年的用多行字符串表示的 <em>m</em> 列年历。可选参数 <em>w</em><em>l</em><em>c</em> 分别表示日期列宽,周的行距,和月与月之间的纵向间隔。同样依赖于构造器或者 <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> 方法指定的每周的第一天是哪一天。可以生成年历的最早的年是哪一年依赖于使用的平台。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.TextCalendar.pryear">
<code class="sig-name descname">pryear</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">w=2</em>, <em class="sig-param">l=1</em>, <em class="sig-param">c=6</em>, <em class="sig-param">m=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.TextCalendar.pryear" title="永久链接至目标"></a></dt>
<dd><p>调用 <a class="reference internal" href="#calendar.TextCalendar.formatyear" title="calendar.TextCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a> 方法并打印返回的年历。</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="calendar.HTMLCalendar">
<em class="property">class </em><code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">HTMLCalendar</code><span class="sig-paren">(</span><em class="sig-param">firstweekday=0</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar" title="永久链接至目标"></a></dt>
<dd><p>可以使用这个类生成 HTML 日历。</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> 实例有以下方法:</p>
<dl class="method">
<dt id="calendar.HTMLCalendar.formatmonth">
<code class="sig-name descname">formatmonth</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">themonth</em>, <em class="sig-param">withyear=True</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatmonth" title="永久链接至目标"></a></dt>
<dd><p>返回一个 HTML 表格作为指定年月的日历。 <em>withyear</em> 为真,则年份将会包含在表头,否则只显示月份。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.HTMLCalendar.formatyear">
<code class="sig-name descname">formatyear</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">width=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatyear" title="永久链接至目标"></a></dt>
<dd><p>返回一个 HTML 表格作为指定年份的日历。 <em>width</em> (默认为3) 用于规定每一行显示月份的数量。</p>
</dd></dl>
<dl class="method">
<dt id="calendar.HTMLCalendar.formatyearpage">
<code class="sig-name descname">formatyearpage</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">width=3</em>, <em class="sig-param">css='calendar.css'</em>, <em class="sig-param">encoding=None</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.HTMLCalendar.formatyearpage" title="永久链接至目标"></a></dt>
<dd><p>返回一个完整的 HTML 页面作为指定年份的日历。 <em>width*(默认为3) 用于规定每一行显示的月份数量。 *css</em> 为层叠样式表的名字。如果不使用任何层叠样式表,可以使用 <a class="reference internal" href="constants.html#None" title="None"><code class="xref py py-const docutils literal notranslate"><span class="pre">None</span></code></a><em>encoding</em> 为输出页面的编码 (默认为系统的默认编码)。</p>
</dd></dl>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> 有以下属性,你可以重写它们来自定义应用日历的样式。</p>
<dl class="attribute">
<dt id="calendar.HTMLCalendar.cssclasses">
<code class="sig-name descname">cssclasses</code><a class="headerlink" href="#calendar.HTMLCalendar.cssclasses" title="永久链接至目标"></a></dt>
<dd><p>一个对应星期一到星期天的 CSS class 列表。默认列表为</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;mon&quot;</span><span class="p">,</span> <span class="s2">&quot;tue&quot;</span><span class="p">,</span> <span class="s2">&quot;wed&quot;</span><span class="p">,</span> <span class="s2">&quot;thu&quot;</span><span class="p">,</span> <span class="s2">&quot;fri&quot;</span><span class="p">,</span> <span class="s2">&quot;sat&quot;</span><span class="p">,</span> <span class="s2">&quot;sun&quot;</span><span class="p">]</span>
</pre></div>
</div>
<p>可以向每天加入其它样式</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;mon text-bold&quot;</span><span class="p">,</span> <span class="s2">&quot;tue&quot;</span><span class="p">,</span> <span class="s2">&quot;wed&quot;</span><span class="p">,</span> <span class="s2">&quot;thu&quot;</span><span class="p">,</span> <span class="s2">&quot;fri&quot;</span><span class="p">,</span> <span class="s2">&quot;sat&quot;</span><span class="p">,</span> <span class="s2">&quot;sun red&quot;</span><span class="p">]</span>
</pre></div>
</div>
<p>需要注意的是列表的长度必须为7。</p>
</dd></dl>
<dl class="attribute">
<dt id="calendar.HTMLCalendar.cssclass_noday">
<code class="sig-name descname">cssclass_noday</code><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_noday" title="永久链接至目标"></a></dt>
<dd><p>工作日的 CSS 类在上个月或下个月发生。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="calendar.HTMLCalendar.cssclasses_weekday_head">
<code class="sig-name descname">cssclasses_weekday_head</code><a class="headerlink" href="#calendar.HTMLCalendar.cssclasses_weekday_head" title="永久链接至目标"></a></dt>
<dd><p>用于标题行中的工作日名称的 CSS 类 列表。默认值与 <a class="reference internal" href="#calendar.HTMLCalendar.cssclasses" title="calendar.HTMLCalendar.cssclasses"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cssclasses</span></code></a> 相同。</p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="calendar.HTMLCalendar.cssclass_month_head">
<code class="sig-name descname">cssclass_month_head</code><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_month_head" title="永久链接至目标"></a></dt>
<dd><p>月份的头 CSS 类(由 <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonthname()</span></code> 使用)。默认值为 <code class="docutils literal notranslate"><span class="pre">&quot;month&quot;</span></code></p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="calendar.HTMLCalendar.cssclass_month">
<code class="sig-name descname">cssclass_month</code><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_month" title="永久链接至目标"></a></dt>
<dd><p>某个月的月历的 CSS 类(由 <a class="reference internal" href="#calendar.HTMLCalendar.formatmonth" title="calendar.HTMLCalendar.formatmonth"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code></a> 使用)。默认值为 <code class="docutils literal notranslate"><span class="pre">&quot;month&quot;</span></code></p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="calendar.HTMLCalendar.cssclass_year">
<code class="sig-name descname">cssclass_year</code><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_year" title="永久链接至目标"></a></dt>
<dd><p>某年的年历的 CSS 类(由 <a class="reference internal" href="#calendar.HTMLCalendar.formatyear" title="calendar.HTMLCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a> 使用)。默认值为 <code class="docutils literal notranslate"><span class="pre">&quot;year&quot;</span></code></p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<dl class="attribute">
<dt id="calendar.HTMLCalendar.cssclass_year_head">
<code class="sig-name descname">cssclass_year_head</code><a class="headerlink" href="#calendar.HTMLCalendar.cssclass_year_head" title="永久链接至目标"></a></dt>
<dd><p>年历的·表头 CSS 类(由 <a class="reference internal" href="#calendar.HTMLCalendar.formatyear" title="calendar.HTMLCalendar.formatyear"><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code></a> 使用)。默认值为 <code class="docutils literal notranslate"><span class="pre">&quot;year&quot;</span></code></p>
<div class="versionadded">
<p><span class="versionmodified added">3.7 新版功能.</span></p>
</div>
</dd></dl>
<p>需要注意的是,尽管上面命名的样式类都是单独出现的(如: <code class="docutils literal notranslate"><span class="pre">cssclass_month</span></code> <code class="docutils literal notranslate"><span class="pre">cssclass_noday</span></code>), 但我们可以使用空格将样式类列表中的多个元素分隔开,例如:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="s2">&quot;text-bold text-red&quot;</span>
</pre></div>
</div>
<p>下面是一个如何自定义 <code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code> 的示例</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">CustomHTMLCal</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">HTMLCalendar</span><span class="p">):</span>
<span class="n">cssclasses</span> <span class="o">=</span> <span class="p">[</span><span class="n">style</span> <span class="o">+</span> <span class="s2">&quot; text-nowrap&quot;</span> <span class="k">for</span> <span class="n">style</span> <span class="ow">in</span>
<span class="n">calendar</span><span class="o">.</span><span class="n">HTMLCalendar</span><span class="o">.</span><span class="n">cssclasses</span><span class="p">]</span>
<span class="n">cssclass_month_head</span> <span class="o">=</span> <span class="s2">&quot;text-center month-head&quot;</span>
<span class="n">cssclass_month</span> <span class="o">=</span> <span class="s2">&quot;text-center month&quot;</span>
<span class="n">cssclass_year</span> <span class="o">=</span> <span class="s2">&quot;text-italic lead&quot;</span>
</pre></div>
</div>
</dd></dl>
<dl class="class">
<dt id="calendar.LocaleTextCalendar">
<em class="property">class </em><code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">LocaleTextCalendar</code><span class="sig-paren">(</span><em class="sig-param">firstweekday=0</em>, <em class="sig-param">locale=None</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.LocaleTextCalendar" title="永久链接至目标"></a></dt>
<dd><p>这个子类 <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> 可以在构造函数中传递一个语言环境名称,并且返回月份和星期几的名称在特定语言环境中。如果此语言环境包含编码,则包含月份和工作日名称的所有字符串将作为 unicode 返回。</p>
</dd></dl>
<dl class="class">
<dt id="calendar.LocaleHTMLCalendar">
<em class="property">class </em><code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">LocaleHTMLCalendar</code><span class="sig-paren">(</span><em class="sig-param">firstweekday=0</em>, <em class="sig-param">locale=None</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.LocaleHTMLCalendar" title="永久链接至目标"></a></dt>
<dd><p>This subclass of <a class="reference internal" href="#calendar.HTMLCalendar" title="calendar.HTMLCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">HTMLCalendar</span></code></a> can be passed a locale name in the
constructor and will return month and weekday names in the specified
locale. If this locale includes an encoding all strings containing month and
weekday names will be returned as unicode.</p>
</dd></dl>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>这两个类的 <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatweekday()</span></code><code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonthname()</span></code> 方法临时更改dang当前区域至给定 <em>locale</em> 。由于当前的区域设置是进程范围的设置,因此它们不是线程安全的。</p>
</div>
<p>这个模块为简单的文本日历提供了下列函数。</p>
<dl class="function">
<dt id="calendar.setfirstweekday">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">setfirstweekday</code><span class="sig-paren">(</span><em class="sig-param">weekday</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.setfirstweekday" title="永久链接至目标"></a></dt>
<dd><p>设置每一周的开始(<code class="docutils literal notranslate"><span class="pre">0</span></code> 表示星期一,<code class="docutils literal notranslate"><span class="pre">6</span></code> 表示星期天)。提供了 <code class="xref py py-const docutils literal notranslate"><span class="pre">MONDAY</span></code><code class="xref py py-const docutils literal notranslate"><span class="pre">TUESDAY</span></code><code class="xref py py-const docutils literal notranslate"><span class="pre">WEDNESDAY</span></code><code class="xref py py-const docutils literal notranslate"><span class="pre">THURSDAY</span></code><code class="xref py py-const docutils literal notranslate"><span class="pre">FRIDAY</span></code><code class="xref py py-const docutils literal notranslate"><span class="pre">SATURDAY</span></code><code class="xref py py-const docutils literal notranslate"><span class="pre">SUNDAY</span></code> 几个常量值作为方便。例如,设置每周的第一天为星期天:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">calendar</span>
<span class="n">calendar</span><span class="o">.</span><span class="n">setfirstweekday</span><span class="p">(</span><span class="n">calendar</span><span class="o">.</span><span class="n">SUNDAY</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="calendar.firstweekday">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">firstweekday</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#calendar.firstweekday" title="永久链接至目标"></a></dt>
<dd><p>返回当前设置的每星期的第一天的数值。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.isleap">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">isleap</code><span class="sig-paren">(</span><em class="sig-param">year</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.isleap" title="永久链接至目标"></a></dt>
<dd><p>如果 <em>year</em> 是闰年则返回 <a class="reference internal" href="constants.html#True" title="True"><code class="xref py py-const docutils literal notranslate"><span class="pre">True</span></code></a> ,否则返回 <a class="reference internal" href="constants.html#False" title="False"><code class="xref py py-const docutils literal notranslate"><span class="pre">False</span></code></a></p>
</dd></dl>
<dl class="function">
<dt id="calendar.leapdays">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">leapdays</code><span class="sig-paren">(</span><em class="sig-param">y1</em>, <em class="sig-param">y2</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.leapdays" title="永久链接至目标"></a></dt>
<dd><p>返回在范围 <em>y1</em><em>y2</em> (不包括 y2之间的闰年的年数其中 <em>y1</em><em>y2</em> 是年份。</p>
<p>此函数对于跨越世纪初的范围也适用。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.weekday">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">weekday</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em>, <em class="sig-param">day</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.weekday" title="永久链接至目标"></a></dt>
<dd><p>返回某年( <code class="docutils literal notranslate"><span class="pre">1970</span></code> -- ...),某月( <code class="docutils literal notranslate"><span class="pre">1</span></code> -- <code class="docutils literal notranslate"><span class="pre">12</span></code> ),某日( <code class="docutils literal notranslate"><span class="pre">1</span></code> -- <code class="docutils literal notranslate"><span class="pre">31</span></code> )是星期几( <code class="docutils literal notranslate"><span class="pre">0</span></code> 是星期一)。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.weekheader">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">weekheader</code><span class="sig-paren">(</span><em class="sig-param">n</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.weekheader" title="永久链接至目标"></a></dt>
<dd><p>返回一个包含星期几的缩写名的头。 <em>n</em> 指定星期几缩写的字符宽度。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.monthrange">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">monthrange</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.monthrange" title="永久链接至目标"></a></dt>
<dd><p>返回指定 <em>年份</em> 的指定 <em>月份</em> 的第一天是星期几和这个月的天数。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.monthcalendar">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">monthcalendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">month</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.monthcalendar" title="永久链接至目标"></a></dt>
<dd><p>返回表示一个月的日历的矩阵。 每一行代表一周;此月份外的日子由零表示。 每周从周一开始,除非使用 <a class="reference internal" href="#calendar.setfirstweekday" title="calendar.setfirstweekday"><code class="xref py py-func docutils literal notranslate"><span class="pre">setfirstweekday()</span></code></a> 改变设置。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.prmonth">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">prmonth</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">themonth</em>, <em class="sig-param">w=0</em>, <em class="sig-param">l=0</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.prmonth" title="永久链接至目标"></a></dt>
<dd><p>打印由 <a class="reference internal" href="#calendar.month" title="calendar.month"><code class="xref py py-func docutils literal notranslate"><span class="pre">month()</span></code></a> 返回的一个月的日历。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.month">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">month</code><span class="sig-paren">(</span><em class="sig-param">theyear</em>, <em class="sig-param">themonth</em>, <em class="sig-param">w=0</em>, <em class="sig-param">l=0</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.month" title="永久链接至目标"></a></dt>
<dd><p>使用 <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> 类的 <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatmonth()</span></code> 以多行字符串形式返回月份日历。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.prcal">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">prcal</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">w=0</em>, <em class="sig-param">l=0</em>, <em class="sig-param">c=6</em>, <em class="sig-param">m=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.prcal" title="永久链接至目标"></a></dt>
<dd><p>打印由 <a class="reference internal" href="#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-func docutils literal notranslate"><span class="pre">calendar()</span></code></a> 返回的整年的日历。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.calendar">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">calendar</code><span class="sig-paren">(</span><em class="sig-param">year</em>, <em class="sig-param">w=2</em>, <em class="sig-param">l=1</em>, <em class="sig-param">c=6</em>, <em class="sig-param">m=3</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.calendar" title="永久链接至目标"></a></dt>
<dd><p>使用 <a class="reference internal" href="#calendar.TextCalendar" title="calendar.TextCalendar"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextCalendar</span></code></a> 类的 <code class="xref py py-meth docutils literal notranslate"><span class="pre">formatyear()</span></code> 返回整年的3列的日历以多行字符串的形式。</p>
</dd></dl>
<dl class="function">
<dt id="calendar.timegm">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">timegm</code><span class="sig-paren">(</span><em class="sig-param">tuple</em><span class="sig-paren">)</span><a class="headerlink" href="#calendar.timegm" title="永久链接至目标"></a></dt>
<dd><p>一个不相关但很好用的函数,它接受一个时间元组例如 <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> 模块中的 <a class="reference internal" href="time.html#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">gmtime()</span></code></a> 函数的返回并返回相应的 Unix 时间戳值,假定 1970 年开始计数, POSIX 编码。实际上, <a class="reference internal" href="time.html#time.gmtime" title="time.gmtime"><code class="xref py py-func docutils literal notranslate"><span class="pre">time.gmtime()</span></code></a><a class="reference internal" href="#calendar.timegm" title="calendar.timegm"><code class="xref py py-func docutils literal notranslate"><span class="pre">timegm()</span></code></a> 是彼此相反的。</p>
</dd></dl>
<p><a class="reference internal" href="#module-calendar" title="calendar: Functions for working with calendars, including some emulation of the Unix cal program."><code class="xref py py-mod docutils literal notranslate"><span class="pre">calendar</span></code></a> 模块导出以下数据属性:</p>
<dl class="data">
<dt id="calendar.day_name">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">day_name</code><a class="headerlink" href="#calendar.day_name" title="永久链接至目标"></a></dt>
<dd><p>在当前语言环境下表示星期几的数组。</p>
</dd></dl>
<dl class="data">
<dt id="calendar.day_abbr">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">day_abbr</code><a class="headerlink" href="#calendar.day_abbr" title="永久链接至目标"></a></dt>
<dd><p>在当前语言环境下表示星期几缩写的数组。</p>
</dd></dl>
<dl class="data">
<dt id="calendar.month_name">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">month_name</code><a class="headerlink" href="#calendar.month_name" title="永久链接至目标"></a></dt>
<dd><p>在当前语言环境下表示一年中月份的数组。这遵循一月的月号为 1 的通常惯例,所以它的长度为 13 且 <code class="docutils literal notranslate"><span class="pre">month_name[0]</span></code> 是空字符串。</p>
</dd></dl>
<dl class="data">
<dt id="calendar.month_abbr">
<code class="sig-prename descclassname">calendar.</code><code class="sig-name descname">month_abbr</code><a class="headerlink" href="#calendar.month_abbr" title="永久链接至目标"></a></dt>
<dd><p>在当前语言环境下表示月份简写的数组。这遵循一月的月号为 1 的通常惯例,所以它的长度为 13 且 <code class="docutils literal notranslate"><span class="pre">month_abbr[0]</span></code> 是空字符串。</p>
</dd></dl>
<div class="admonition seealso">
<p class="admonition-title">参见</p>
<dl class="simple">
<dt>模块 <a class="reference internal" href="datetime.html#module-datetime" title="datetime: Basic date and time types."><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code></a></dt><dd><p>为日期和时间提供与 <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a> 模块相似功能的面向对象接口。</p>
</dd>
<dt>模块 <a class="reference internal" href="time.html#module-time" title="time: Time access and conversions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">time</span></code></a></dt><dd><p>底层时间相关函数。</p>
</dd>
</dl>
</div>
</section>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h4>上一个主题</h4>
<p class="topless"><a href="datetime.html"
title="上一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">datetime</span></code> --- 基本日期和时间类型</a></p>
<h4>下一个主题</h4>
<p class="topless"><a href="collections.html"
title="下一章"><code class="xref py py-mod docutils literal notranslate"><span class="pre">collections</span></code> --- 容器数据类型</a></p>
<div role="note" aria-label="source link">
<h3>本页</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">报告 Bug</a></li>
<li>
<a href="https://github.com/python/cpython/blob/3.8/Doc/library/calendar.rst"
rel="nofollow">显示源代码
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>导航</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="总目录"
>索引</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python 模块索引"
>模块</a> |</li>
<li class="right" >
<a href="collections.html" title="collections --- 容器数据类型"
>下一页</a> |</li>
<li class="right" >
<a href="datetime.html" title="datetime --- 基本日期和时间类型"
>上一页</a> |</li>
<li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://www.python.org/">Python</a> &#187;</li>
<li class="switchers">
<div class="language_switcher_placeholder"></div>
<div class="version_switcher_placeholder"></div>
</li>
<li>
</li>
<li id="cpython-language-and-version">
<a href="../index.html">3.8.20 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="datatypes.html" >数据类型</a> &#187;</li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="快速搜索" aria-label="快速搜索" type="text" name="q" />
<input type="submit" value="转向" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
|
</li>
</ul>
</div>
<div class="footer">
&copy; <a href="../copyright.html">版权所有</a> 2001-2024, Python Software Foundation.
<br />
This page is licensed under the Python Software Foundation License Version 2.
<br />
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
<br />
<br />
The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
<br />
最后更新于 12月 09, 2024.
<a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
<br />
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
</div>
</body>
</html>