<!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>7. String Services — Python v3.1.1 documentation</title> <link rel="stylesheet" href="../_static/default.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.1.1', COLLAPSE_MODINDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python v3.1.1 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.1.1 documentation" href="../index.html" /> <link rel="up" title="The Python Standard Library" href="index.html" /> <link rel="next" title="7.1. string β Common string operations" href="string.html" /> <link rel="prev" title="6. Built-in Exceptions" href="exceptions.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> </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="../modindex.html" title="Global Module Index" accesskey="M">modules</a> |</li> <li class="right" > <a href="string.html" title="7.1. string β Common string operations" accesskey="N">next</a> |</li> <li class="right" > <a href="exceptions.html" title="6. Built-in Exceptions" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="../index.html">Python v3.1.1 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="string-services"> <span id="stringservices"></span><h1>7. String Services<a class="headerlink" href="#string-services" title="Permalink to this headline">ΒΆ</a></h1> <p>The modules described in this chapter provide a wide range of string manipulation operations.</p> <p>In addition, Python’s built-in string classes support the sequence type methods described in the <a class="reference external" href="stdtypes.html#typesseq"><em>Sequence Types — str, bytes, bytearray, list, tuple, range</em></a> section, and also the string-specific methods described in the <a class="reference external" href="stdtypes.html#string-methods"><em>String Methods</em></a> section. To output formatted strings, see the <a class="reference external" href="string.html#string-formatting"><em>String Formatting</em></a> section. Also, see the <a title="Regular expression operations." class="reference external" href="re.html#module-re"><tt class="xref docutils literal"><span class="pre">re</span></tt></a> module for string functions based on regular expressions.</p> <ul> <li class="toctree-l1"><a class="reference external" href="string.html">7.1. <tt class="docutils literal"><span class="pre">string</span></tt> — Common string operations</a><ul> <li class="toctree-l2"><a class="reference external" href="string.html#string-constants">7.1.1. String constants</a></li> <li class="toctree-l2"><a class="reference external" href="string.html#string-formatting">7.1.2. String Formatting</a></li> <li class="toctree-l2"><a class="reference external" href="string.html#format-string-syntax">7.1.3. Format String Syntax</a><ul> <li class="toctree-l3"><a class="reference external" href="string.html#format-specification-mini-language">7.1.3.1. Format Specification Mini-Language</a></li> </ul> </li> <li class="toctree-l2"><a class="reference external" href="string.html#template-strings">7.1.4. Template strings</a></li> <li class="toctree-l2"><a class="reference external" href="string.html#helper-functions">7.1.5. Helper functions</a></li> </ul> </li> <li class="toctree-l1"><a class="reference external" href="re.html">7.2. <tt class="docutils literal"><span class="pre">re</span></tt> — Regular expression operations</a><ul> <li class="toctree-l2"><a class="reference external" href="re.html#regular-expression-syntax">7.2.1. Regular Expression Syntax</a></li> <li class="toctree-l2"><a class="reference external" href="re.html#matching-vs-searching">7.2.2. Matching vs Searching</a></li> <li class="toctree-l2"><a class="reference external" href="re.html#module-contents">7.2.3. Module Contents</a></li> <li class="toctree-l2"><a class="reference external" href="re.html#regular-expression-objects">7.2.4. Regular Expression Objects</a></li> <li class="toctree-l2"><a class="reference external" href="re.html#match-objects">7.2.5. Match Objects</a></li> <li class="toctree-l2"><a class="reference external" href="re.html#examples">7.2.6. Examples</a><ul> <li class="toctree-l3"><a class="reference external" href="re.html#checking-for-a-pair">7.2.6.1. Checking For a Pair</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#simulating-scanf">7.2.6.2. Simulating scanf()</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#avoiding-recursion">7.2.6.3. Avoiding recursion</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#search-vs-match">7.2.6.4. search() vs. match()</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#making-a-phonebook">7.2.6.5. Making a Phonebook</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#text-munging">7.2.6.6. Text Munging</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#finding-all-adverbs">7.2.6.7. Finding all Adverbs</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#finding-all-adverbs-and-their-positions">7.2.6.8. Finding all Adverbs and their Positions</a></li> <li class="toctree-l3"><a class="reference external" href="re.html#raw-string-notation">7.2.6.9. Raw String Notation</a></li> </ul> </li> </ul> </li> <li class="toctree-l1"><a class="reference external" href="struct.html">7.3. <tt class="docutils literal"><span class="pre">struct</span></tt> — Interpret bytes as packed binary data</a><ul> <li class="toctree-l2"><a class="reference external" href="struct.html#struct-objects">7.3.1. Struct Objects</a></li> </ul> </li> <li class="toctree-l1"><a class="reference external" href="difflib.html">7.4. <tt class="docutils literal"><span class="pre">difflib</span></tt> — Helpers for computing deltas</a><ul> <li class="toctree-l2"><a class="reference external" href="difflib.html#sequencematcher-objects">7.4.1. SequenceMatcher Objects</a></li> <li class="toctree-l2"><a class="reference external" href="difflib.html#sequencematcher-examples">7.4.2. SequenceMatcher Examples</a></li> <li class="toctree-l2"><a class="reference external" href="difflib.html#differ-objects">7.4.3. Differ Objects</a></li> <li class="toctree-l2"><a class="reference external" href="difflib.html#differ-example">7.4.4. Differ Example</a></li> <li class="toctree-l2"><a class="reference external" href="difflib.html#a-command-line-interface-to-difflib">7.4.5. A command-line interface to difflib</a></li> </ul> </li> <li class="toctree-l1"><a class="reference external" href="textwrap.html">7.5. <tt class="docutils literal"><span class="pre">textwrap</span></tt> — Text wrapping and filling</a></li> <li class="toctree-l1"><a class="reference external" href="codecs.html">7.6. <tt class="docutils literal"><span class="pre">codecs</span></tt> — Codec registry and base classes</a><ul> <li class="toctree-l2"><a class="reference external" href="codecs.html#codec-base-classes">7.6.1. Codec Base Classes</a><ul> <li class="toctree-l3"><a class="reference external" href="codecs.html#codec-objects">7.6.1.1. Codec Objects</a></li> <li class="toctree-l3"><a class="reference external" href="codecs.html#incrementalencoder-objects">7.6.1.2. IncrementalEncoder Objects</a></li> <li class="toctree-l3"><a class="reference external" href="codecs.html#incrementaldecoder-objects">7.6.1.3. IncrementalDecoder Objects</a></li> <li class="toctree-l3"><a class="reference external" href="codecs.html#streamwriter-objects">7.6.1.4. StreamWriter Objects</a></li> <li class="toctree-l3"><a class="reference external" href="codecs.html#streamreader-objects">7.6.1.5. StreamReader Objects</a></li> <li class="toctree-l3"><a class="reference external" href="codecs.html#streamreaderwriter-objects">7.6.1.6. StreamReaderWriter Objects</a></li> <li class="toctree-l3"><a class="reference external" href="codecs.html#streamrecoder-objects">7.6.1.7. StreamRecoder Objects</a></li> </ul> </li> <li class="toctree-l2"><a class="reference external" href="codecs.html#encodings-and-unicode">7.6.2. Encodings and Unicode</a></li> <li class="toctree-l2"><a class="reference external" href="codecs.html#standard-encodings">7.6.3. Standard Encodings</a></li> <li class="toctree-l2"><a class="reference external" href="codecs.html#module-encodings.idna">7.6.4. <tt class="docutils literal"><span class="pre">encodings.idna</span></tt> — Internationalized Domain Names in Applications</a></li> <li class="toctree-l2"><a class="reference external" href="codecs.html#module-encodings.utf_8_sig">7.6.5. <tt class="docutils literal"><span class="pre">encodings.utf_8_sig</span></tt> — UTF-8 codec with BOM signature</a></li> </ul> </li> <li class="toctree-l1"><a class="reference external" href="unicodedata.html">7.7. <tt class="docutils literal"><span class="pre">unicodedata</span></tt> — Unicode Database</a></li> <li class="toctree-l1"><a class="reference external" href="stringprep.html">7.8. <tt class="docutils literal"><span class="pre">stringprep</span></tt> — Internet String Preparation</a></li> </ul> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="exceptions.html" title="previous chapter">6. Built-in Exceptions</a></p> <h4>Next topic</h4> <p class="topless"><a href="string.html" title="next chapter">7.1. <tt class="docutils literal docutils literal docutils literal"><span class="pre">string</span></tt> — Common string operations</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/library/strings.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="../modindex.html" title="Global Module Index" >modules</a> |</li> <li class="right" > <a href="string.html" title="7.1. string β Common string operations" >next</a> |</li> <li class="right" > <a href="exceptions.html" title="6. Built-in Exceptions" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="../index.html">Python v3.1.1 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-2009, 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 Aug 16, 2009. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.2. </div> </body> </html>