<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>8. Data Types — Python v3.3.2 documentation</title> <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '3.3.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python v3.3.2 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python v3.3.2 documentation" href="../index.html" /> <link rel="up" title="The Python Standard Library" href="index.html" /> <link rel="next" title="8.1. datetime — Basic date and time types" href="datetime.html" /> <link rel="prev" title="7.2. codecs — Codec registry and base classes" href="codecs.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="datetime.html" title="8.1. datetime — Basic date and time types" accesskey="N">next</a> |</li> <li class="right" > <a href="codecs.html" title="7.2. codecs — Codec registry and base classes" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">3.3.2 Documentation</a> » </li> <li><a href="index.html" accesskey="U">The Python Standard Library</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="data-types"> <span id="datatypes"></span><h1>8. Data Types<a class="headerlink" href="#data-types" title="Permalink to this headline">¶</a></h1> <p>The modules described in this chapter provide a variety of specialized data types such as dates and times, fixed-type arrays, heap queues, synchronized queues, and sets.</p> <p>Python also provides some built-in data types, in particular, <a class="reference internal" href="stdtypes.html#dict" title="dict"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a>, <a class="reference internal" href="stdtypes.html#list" title="list"><tt class="xref py py-class docutils literal"><span class="pre">list</span></tt></a>, <a class="reference internal" href="stdtypes.html#set" title="set"><tt class="xref py py-class docutils literal"><span class="pre">set</span></tt></a> and <a class="reference internal" href="stdtypes.html#frozenset" title="frozenset"><tt class="xref py py-class docutils literal"><span class="pre">frozenset</span></tt></a>, and <a class="reference internal" href="stdtypes.html#tuple" title="tuple"><tt class="xref py py-class docutils literal"><span class="pre">tuple</span></tt></a>. The <a class="reference internal" href="stdtypes.html#str" title="str"><tt class="xref py py-class docutils literal"><span class="pre">str</span></tt></a> class is used to hold Unicode strings, and the <a class="reference internal" href="functions.html#bytes" title="bytes"><tt class="xref py py-class docutils literal"><span class="pre">bytes</span></tt></a> class is used to hold binary data.</p> <p>The following modules are documented in this chapter:</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="datetime.html">8.1. <tt class="docutils literal"><span class="pre">datetime</span></tt> — Basic date and time types</a><ul> <li class="toctree-l2"><a class="reference internal" href="datetime.html#available-types">8.1.1. Available Types</a></li> <li class="toctree-l2"><a class="reference internal" href="datetime.html#timedelta-objects">8.1.2. <tt class="docutils literal"><span class="pre">timedelta</span></tt> Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="datetime.html#date-objects">8.1.3. <tt class="docutils literal"><span class="pre">date</span></tt> Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="datetime.html#datetime-objects">8.1.4. <tt class="docutils literal"><span class="pre">datetime</span></tt> Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="datetime.html#time-objects">8.1.5. <tt class="docutils literal"><span class="pre">time</span></tt> Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="datetime.html#tzinfo-objects">8.1.6. <tt class="docutils literal"><span class="pre">tzinfo</span></tt> Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="datetime.html#timezone-objects">8.1.7. <tt class="docutils literal"><span class="pre">timezone</span></tt> Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="datetime.html#strftime-and-strptime-behavior">8.1.8. <tt class="docutils literal"><span class="pre">strftime()</span></tt> and <tt class="docutils literal"><span class="pre">strptime()</span></tt> Behavior</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="calendar.html">8.2. <tt class="docutils literal"><span class="pre">calendar</span></tt> — General calendar-related functions</a></li> <li class="toctree-l1"><a class="reference internal" href="collections.html">8.3. <tt class="docutils literal"><span class="pre">collections</span></tt> — Container datatypes</a><ul> <li class="toctree-l2"><a class="reference internal" href="collections.html#chainmap-objects">8.3.1. <tt class="docutils literal"><span class="pre">ChainMap</span></tt> objects</a><ul> <li class="toctree-l3"><a class="reference internal" href="collections.html#chainmap-examples-and-recipes">8.3.1.1. <tt class="docutils literal"><span class="pre">ChainMap</span></tt> Examples and Recipes</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="collections.html#counter-objects">8.3.2. <tt class="docutils literal"><span class="pre">Counter</span></tt> objects</a></li> <li class="toctree-l2"><a class="reference internal" href="collections.html#deque-objects">8.3.3. <tt class="docutils literal"><span class="pre">deque</span></tt> objects</a><ul> <li class="toctree-l3"><a class="reference internal" href="collections.html#deque-recipes">8.3.3.1. <tt class="docutils literal"><span class="pre">deque</span></tt> Recipes</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="collections.html#defaultdict-objects">8.3.4. <tt class="docutils literal"><span class="pre">defaultdict</span></tt> objects</a><ul> <li class="toctree-l3"><a class="reference internal" href="collections.html#defaultdict-examples">8.3.4.1. <tt class="docutils literal"><span class="pre">defaultdict</span></tt> Examples</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="collections.html#namedtuple-factory-function-for-tuples-with-named-fields">8.3.5. <tt class="docutils literal"><span class="pre">namedtuple()</span></tt> Factory Function for Tuples with Named Fields</a></li> <li class="toctree-l2"><a class="reference internal" href="collections.html#ordereddict-objects">8.3.6. <tt class="docutils literal"><span class="pre">OrderedDict</span></tt> objects</a><ul> <li class="toctree-l3"><a class="reference internal" href="collections.html#ordereddict-examples-and-recipes">8.3.6.1. <tt class="docutils literal"><span class="pre">OrderedDict</span></tt> Examples and Recipes</a></li> </ul> </li> <li class="toctree-l2"><a class="reference internal" href="collections.html#userdict-objects">8.3.7. <tt class="docutils literal"><span class="pre">UserDict</span></tt> objects</a></li> <li class="toctree-l2"><a class="reference internal" href="collections.html#userlist-objects">8.3.8. <tt class="docutils literal"><span class="pre">UserList</span></tt> objects</a></li> <li class="toctree-l2"><a class="reference internal" href="collections.html#userstring-objects">8.3.9. <tt class="docutils literal"><span class="pre">UserString</span></tt> objects</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="collections.abc.html">8.4. <tt class="docutils literal"><span class="pre">collections.abc</span></tt> — Abstract Base Classes for Containers</a><ul> <li class="toctree-l2"><a class="reference internal" href="collections.abc.html#collections-abstract-base-classes">8.4.1. Collections Abstract Base Classes</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="heapq.html">8.5. <tt class="docutils literal"><span class="pre">heapq</span></tt> — Heap queue algorithm</a><ul> <li class="toctree-l2"><a class="reference internal" href="heapq.html#basic-examples">8.5.1. Basic Examples</a></li> <li class="toctree-l2"><a class="reference internal" href="heapq.html#priority-queue-implementation-notes">8.5.2. Priority Queue Implementation Notes</a></li> <li class="toctree-l2"><a class="reference internal" href="heapq.html#theory">8.5.3. Theory</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="bisect.html">8.6. <tt class="docutils literal"><span class="pre">bisect</span></tt> — Array bisection algorithm</a><ul> <li class="toctree-l2"><a class="reference internal" href="bisect.html#searching-sorted-lists">8.6.1. Searching Sorted Lists</a></li> <li class="toctree-l2"><a class="reference internal" href="bisect.html#other-examples">8.6.2. Other Examples</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="array.html">8.7. <tt class="docutils literal"><span class="pre">array</span></tt> — Efficient arrays of numeric values</a></li> <li class="toctree-l1"><a class="reference internal" href="weakref.html">8.8. <tt class="docutils literal"><span class="pre">weakref</span></tt> — Weak references</a><ul> <li class="toctree-l2"><a class="reference internal" href="weakref.html#weak-reference-objects">8.8.1. Weak Reference Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="weakref.html#example">8.8.2. Example</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="types.html">8.9. <tt class="docutils literal"><span class="pre">types</span></tt> — Dynamic type creation and names for built-in types</a><ul> <li class="toctree-l2"><a class="reference internal" href="types.html#dynamic-type-creation">8.9.1. Dynamic Type Creation</a></li> <li class="toctree-l2"><a class="reference internal" href="types.html#standard-interpreter-types">8.9.2. Standard Interpreter Types</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="copy.html">8.10. <tt class="docutils literal"><span class="pre">copy</span></tt> — Shallow and deep copy operations</a></li> <li class="toctree-l1"><a class="reference internal" href="pprint.html">8.11. <tt class="docutils literal"><span class="pre">pprint</span></tt> — Data pretty printer</a><ul> <li class="toctree-l2"><a class="reference internal" href="pprint.html#prettyprinter-objects">8.11.1. PrettyPrinter Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="pprint.html#example">8.11.2. Example</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="reprlib.html">8.12. <tt class="docutils literal"><span class="pre">reprlib</span></tt> — Alternate <tt class="docutils literal"><span class="pre">repr()</span></tt> implementation</a><ul> <li class="toctree-l2"><a class="reference internal" href="reprlib.html#repr-objects">8.12.1. Repr Objects</a></li> <li class="toctree-l2"><a class="reference internal" href="reprlib.html#subclassing-repr-objects">8.12.2. Subclassing Repr Objects</a></li> </ul> </li> </ul> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="codecs.html" title="previous chapter">7.2. <tt class="docutils literal docutils literal"><span class="pre">codecs</span></tt> — Codec registry and base classes</a></p> <h4>Next topic</h4> <p class="topless"><a href="datetime.html" title="next chapter">8.1. <tt class="docutils literal docutils literal"><span class="pre">datetime</span></tt> — Basic date and time types</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/datatypes.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="datetime.html" title="8.1. datetime — Basic date and time types" >next</a> |</li> <li class="right" > <a href="codecs.html" title="7.2. codecs — Codec registry and base classes" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">3.3.2 Documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2013, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on May 15, 2013. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7. </div> </body> </html>