~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-2.7.11-docs-html/library/strings.html

  • Committer: Dave Kuhlman
  • Date: 2016-02-11 21:17:09 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20160211211709-03yaen3cjempbi2m
Updated Python 2.7 docs; added Python 3.5 docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
2
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
3
 
 
4
 
 
5
<html xmlns="http://www.w3.org/1999/xhtml">
 
6
  <head>
 
7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 
8
    
 
9
    <title>7. String Services &mdash; Python 2.7.11 documentation</title>
 
10
    
 
11
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
 
12
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
 
13
    
 
14
    <script type="text/javascript">
 
15
      var DOCUMENTATION_OPTIONS = {
 
16
        URL_ROOT:    '../',
 
17
        VERSION:     '2.7.11',
 
18
        COLLAPSE_INDEX: false,
 
19
        FILE_SUFFIX: '.html',
 
20
        HAS_SOURCE:  true
 
21
      };
 
22
    </script>
 
23
    <script type="text/javascript" src="../_static/jquery.js"></script>
 
24
    <script type="text/javascript" src="../_static/underscore.js"></script>
 
25
    <script type="text/javascript" src="../_static/doctools.js"></script>
 
26
    <script type="text/javascript" src="../_static/sidebar.js"></script>
 
27
    <link rel="search" type="application/opensearchdescription+xml"
 
28
          title="Search within Python 2.7.11 documentation"
 
29
          href="../_static/opensearch.xml"/>
 
30
    <link rel="author" title="About these documents" href="../about.html" />
 
31
    <link rel="copyright" title="Copyright" href="../copyright.html" />
 
32
    <link rel="top" title="Python 2.7.11 documentation" href="../contents.html" />
 
33
    <link rel="up" title="The Python Standard Library" href="index.html" />
 
34
    <link rel="next" title="7.1. string — Common string operations" href="string.html" />
 
35
    <link rel="prev" title="6. Built-in Exceptions" href="exceptions.html" />
 
36
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 
37
    <script type="text/javascript" src="../_static/copybutton.js"></script>
 
38
    <script type="text/javascript" src="../_static/version_switch.js"></script>
 
39
 
 
40
    
 
41
 
 
42
  </head>
 
43
  <body role="document">  
 
44
    <div class="related" role="navigation" aria-label="related navigation">
 
45
      <h3>Navigation</h3>
 
46
      <ul>
 
47
        <li class="right" style="margin-right: 10px">
 
48
          <a href="../genindex.html" title="General Index"
 
49
             accesskey="I">index</a></li>
 
50
        <li class="right" >
 
51
          <a href="../py-modindex.html" title="Python Module Index"
 
52
             >modules</a> |</li>
 
53
        <li class="right" >
 
54
          <a href="string.html" title="7.1. string — Common string operations"
 
55
             accesskey="N">next</a> |</li>
 
56
        <li class="right" >
 
57
          <a href="exceptions.html" title="6. Built-in Exceptions"
 
58
             accesskey="P">previous</a> |</li>
 
59
        <li><img src="../_static/py.png" alt=""
 
60
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
61
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
62
        <li>
 
63
          <span class="version_switcher_placeholder">2.7.11</span>
 
64
          <a href="../index.html">Documentation</a> &raquo;
 
65
        </li>
 
66
 
 
67
          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">The Python Standard Library</a> &raquo;</li> 
 
68
      </ul>
 
69
    </div>    
 
70
 
 
71
    <div class="document">
 
72
      <div class="documentwrapper">
 
73
        <div class="bodywrapper">
 
74
          <div class="body" role="main">
 
75
            
 
76
  <div class="section" id="string-services">
 
77
<span id="stringservices"></span><h1>7. String Services<a class="headerlink" href="#string-services" title="Permalink to this headline">¶</a></h1>
 
78
<p>The modules described in this chapter provide a wide range of string
 
79
manipulation operations.</p>
 
80
<p>In addition, Python&#8217;s built-in string classes support the sequence type
 
81
methods described in the <a class="reference internal" href="stdtypes.html#typesseq"><span>Sequence Types &#8212; str, unicode, list, tuple, bytearray, buffer, xrange</span></a> section, and also the
 
82
string-specific methods described in the <a class="reference internal" href="stdtypes.html#string-methods"><span>String Methods</span></a> section.
 
83
To output formatted strings use template strings or the <code class="docutils literal"><span class="pre">%</span></code> operator
 
84
described in the <a class="reference internal" href="stdtypes.html#string-formatting"><span>String Formatting Operations</span></a> section. Also, see the
 
85
<a class="reference internal" href="re.html#module-re" title="re: Regular expression operations."><code class="xref py py-mod docutils literal"><span class="pre">re</span></code></a> module for string functions based on regular expressions.</p>
 
86
<div class="toctree-wrapper compound">
 
87
<ul>
 
88
<li class="toctree-l1"><a class="reference internal" href="string.html">7.1. <code class="docutils literal"><span class="pre">string</span></code> &#8212; Common string operations</a><ul>
 
89
<li class="toctree-l2"><a class="reference internal" href="string.html#string-constants">7.1.1. String constants</a></li>
 
90
<li class="toctree-l2"><a class="reference internal" href="string.html#custom-string-formatting">7.1.2. Custom String Formatting</a></li>
 
91
<li class="toctree-l2"><a class="reference internal" href="string.html#format-string-syntax">7.1.3. Format String Syntax</a><ul>
 
92
<li class="toctree-l3"><a class="reference internal" href="string.html#format-specification-mini-language">7.1.3.1. Format Specification Mini-Language</a></li>
 
93
<li class="toctree-l3"><a class="reference internal" href="string.html#format-examples">7.1.3.2. Format examples</a></li>
 
94
</ul>
 
95
</li>
 
96
<li class="toctree-l2"><a class="reference internal" href="string.html#template-strings">7.1.4. Template strings</a></li>
 
97
<li class="toctree-l2"><a class="reference internal" href="string.html#string-functions">7.1.5. String functions</a></li>
 
98
<li class="toctree-l2"><a class="reference internal" href="string.html#deprecated-string-functions">7.1.6. Deprecated string functions</a></li>
 
99
</ul>
 
100
</li>
 
101
<li class="toctree-l1"><a class="reference internal" href="re.html">7.2. <code class="docutils literal"><span class="pre">re</span></code> &#8212; Regular expression operations</a><ul>
 
102
<li class="toctree-l2"><a class="reference internal" href="re.html#regular-expression-syntax">7.2.1. Regular Expression Syntax</a></li>
 
103
<li class="toctree-l2"><a class="reference internal" href="re.html#module-contents">7.2.2. Module Contents</a></li>
 
104
<li class="toctree-l2"><a class="reference internal" href="re.html#regular-expression-objects">7.2.3. Regular Expression Objects</a></li>
 
105
<li class="toctree-l2"><a class="reference internal" href="re.html#match-objects">7.2.4. Match Objects</a></li>
 
106
<li class="toctree-l2"><a class="reference internal" href="re.html#examples">7.2.5. Examples</a><ul>
 
107
<li class="toctree-l3"><a class="reference internal" href="re.html#checking-for-a-pair">7.2.5.1. Checking For a Pair</a></li>
 
108
<li class="toctree-l3"><a class="reference internal" href="re.html#simulating-scanf">7.2.5.2. Simulating scanf()</a></li>
 
109
<li class="toctree-l3"><a class="reference internal" href="re.html#search-vs-match">7.2.5.3. search() vs. match()</a></li>
 
110
<li class="toctree-l3"><a class="reference internal" href="re.html#making-a-phonebook">7.2.5.4. Making a Phonebook</a></li>
 
111
<li class="toctree-l3"><a class="reference internal" href="re.html#text-munging">7.2.5.5. Text Munging</a></li>
 
112
<li class="toctree-l3"><a class="reference internal" href="re.html#finding-all-adverbs">7.2.5.6. Finding all Adverbs</a></li>
 
113
<li class="toctree-l3"><a class="reference internal" href="re.html#finding-all-adverbs-and-their-positions">7.2.5.7. Finding all Adverbs and their Positions</a></li>
 
114
<li class="toctree-l3"><a class="reference internal" href="re.html#raw-string-notation">7.2.5.8. Raw String Notation</a></li>
 
115
</ul>
 
116
</li>
 
117
</ul>
 
118
</li>
 
119
<li class="toctree-l1"><a class="reference internal" href="struct.html">7.3. <code class="docutils literal"><span class="pre">struct</span></code> &#8212; Interpret strings as packed binary data</a><ul>
 
120
<li class="toctree-l2"><a class="reference internal" href="struct.html#functions-and-exceptions">7.3.1. Functions and Exceptions</a></li>
 
121
<li class="toctree-l2"><a class="reference internal" href="struct.html#format-strings">7.3.2. Format Strings</a><ul>
 
122
<li class="toctree-l3"><a class="reference internal" href="struct.html#byte-order-size-and-alignment">7.3.2.1. Byte Order, Size, and Alignment</a></li>
 
123
<li class="toctree-l3"><a class="reference internal" href="struct.html#format-characters">7.3.2.2. Format Characters</a></li>
 
124
<li class="toctree-l3"><a class="reference internal" href="struct.html#examples">7.3.2.3. Examples</a></li>
 
125
</ul>
 
126
</li>
 
127
<li class="toctree-l2"><a class="reference internal" href="struct.html#classes">7.3.3. Classes</a></li>
 
128
</ul>
 
129
</li>
 
130
<li class="toctree-l1"><a class="reference internal" href="difflib.html">7.4. <code class="docutils literal"><span class="pre">difflib</span></code> &#8212; Helpers for computing deltas</a><ul>
 
131
<li class="toctree-l2"><a class="reference internal" href="difflib.html#sequencematcher-objects">7.4.1. SequenceMatcher Objects</a></li>
 
132
<li class="toctree-l2"><a class="reference internal" href="difflib.html#sequencematcher-examples">7.4.2. SequenceMatcher Examples</a></li>
 
133
<li class="toctree-l2"><a class="reference internal" href="difflib.html#differ-objects">7.4.3. Differ Objects</a></li>
 
134
<li class="toctree-l2"><a class="reference internal" href="difflib.html#differ-example">7.4.4. Differ Example</a></li>
 
135
<li class="toctree-l2"><a class="reference internal" href="difflib.html#a-command-line-interface-to-difflib">7.4.5. A command-line interface to difflib</a></li>
 
136
</ul>
 
137
</li>
 
138
<li class="toctree-l1"><a class="reference internal" href="stringio.html">7.5. <code class="docutils literal"><span class="pre">StringIO</span></code> &#8212; Read and write strings as files</a></li>
 
139
<li class="toctree-l1"><a class="reference internal" href="stringio.html#module-cStringIO">7.6. <code class="docutils literal"><span class="pre">cStringIO</span></code> &#8212; Faster version of <code class="docutils literal"><span class="pre">StringIO</span></code></a></li>
 
140
<li class="toctree-l1"><a class="reference internal" href="textwrap.html">7.7. <code class="docutils literal"><span class="pre">textwrap</span></code> &#8212; Text wrapping and filling</a></li>
 
141
<li class="toctree-l1"><a class="reference internal" href="codecs.html">7.8. <code class="docutils literal"><span class="pre">codecs</span></code> &#8212; Codec registry and base classes</a><ul>
 
142
<li class="toctree-l2"><a class="reference internal" href="codecs.html#codec-base-classes">7.8.1. Codec Base Classes</a><ul>
 
143
<li class="toctree-l3"><a class="reference internal" href="codecs.html#codec-objects">7.8.1.1. Codec Objects</a></li>
 
144
<li class="toctree-l3"><a class="reference internal" href="codecs.html#incrementalencoder-objects">7.8.1.2. IncrementalEncoder Objects</a></li>
 
145
<li class="toctree-l3"><a class="reference internal" href="codecs.html#incrementaldecoder-objects">7.8.1.3. IncrementalDecoder Objects</a></li>
 
146
<li class="toctree-l3"><a class="reference internal" href="codecs.html#streamwriter-objects">7.8.1.4. StreamWriter Objects</a></li>
 
147
<li class="toctree-l3"><a class="reference internal" href="codecs.html#streamreader-objects">7.8.1.5. StreamReader Objects</a></li>
 
148
<li class="toctree-l3"><a class="reference internal" href="codecs.html#streamreaderwriter-objects">7.8.1.6. StreamReaderWriter Objects</a></li>
 
149
<li class="toctree-l3"><a class="reference internal" href="codecs.html#streamrecoder-objects">7.8.1.7. StreamRecoder Objects</a></li>
 
150
</ul>
 
151
</li>
 
152
<li class="toctree-l2"><a class="reference internal" href="codecs.html#encodings-and-unicode">7.8.2. Encodings and Unicode</a></li>
 
153
<li class="toctree-l2"><a class="reference internal" href="codecs.html#standard-encodings">7.8.3. Standard Encodings</a></li>
 
154
<li class="toctree-l2"><a class="reference internal" href="codecs.html#python-specific-encodings">7.8.4. Python Specific Encodings</a></li>
 
155
<li class="toctree-l2"><a class="reference internal" href="codecs.html#module-encodings.idna">7.8.5. <code class="docutils literal"><span class="pre">encodings.idna</span></code> &#8212; Internationalized Domain Names in Applications</a></li>
 
156
<li class="toctree-l2"><a class="reference internal" href="codecs.html#module-encodings.utf_8_sig">7.8.6. <code class="docutils literal"><span class="pre">encodings.utf_8_sig</span></code> &#8212; UTF-8 codec with BOM signature</a></li>
 
157
</ul>
 
158
</li>
 
159
<li class="toctree-l1"><a class="reference internal" href="unicodedata.html">7.9. <code class="docutils literal"><span class="pre">unicodedata</span></code> &#8212; Unicode Database</a></li>
 
160
<li class="toctree-l1"><a class="reference internal" href="stringprep.html">7.10. <code class="docutils literal"><span class="pre">stringprep</span></code> &#8212; Internet String Preparation</a></li>
 
161
<li class="toctree-l1"><a class="reference internal" href="fpformat.html">7.11. <code class="docutils literal"><span class="pre">fpformat</span></code> &#8212; Floating point conversions</a></li>
 
162
</ul>
 
163
</div>
 
164
</div>
 
165
 
 
166
 
 
167
          </div>
 
168
        </div>
 
169
      </div>
 
170
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
 
171
        <div class="sphinxsidebarwrapper">
 
172
  <h4>Previous topic</h4>
 
173
  <p class="topless"><a href="exceptions.html"
 
174
                        title="previous chapter">6. Built-in Exceptions</a></p>
 
175
  <h4>Next topic</h4>
 
176
  <p class="topless"><a href="string.html"
 
177
                        title="next chapter">7.1. <code class="docutils literal"><span class="pre">string</span></code> &#8212; Common string operations</a></p>
 
178
<h3>This Page</h3>
 
179
<ul class="this-page-menu">
 
180
  <li><a href="../bugs.html">Report a Bug</a></li>
 
181
  <li><a href="../_sources/library/strings.txt"
 
182
         rel="nofollow">Show Source</a></li>
 
183
</ul>
 
184
 
 
185
<div id="searchbox" style="display: none" role="search">
 
186
  <h3>Quick search</h3>
 
187
    <form class="search" action="../search.html" method="get">
 
188
      <input type="text" name="q" />
 
189
      <input type="submit" value="Go" />
 
190
      <input type="hidden" name="check_keywords" value="yes" />
 
191
      <input type="hidden" name="area" value="default" />
 
192
    </form>
 
193
    <p class="searchtip" style="font-size: 90%">
 
194
    Enter search terms or a module, class or function name.
 
195
    </p>
 
196
</div>
 
197
<script type="text/javascript">$('#searchbox').show(0);</script>
 
198
        </div>
 
199
      </div>
 
200
      <div class="clearer"></div>
 
201
    </div>  
 
202
    <div class="related" role="navigation" aria-label="related navigation">
 
203
      <h3>Navigation</h3>
 
204
      <ul>
 
205
        <li class="right" style="margin-right: 10px">
 
206
          <a href="../genindex.html" title="General Index"
 
207
             >index</a></li>
 
208
        <li class="right" >
 
209
          <a href="../py-modindex.html" title="Python Module Index"
 
210
             >modules</a> |</li>
 
211
        <li class="right" >
 
212
          <a href="string.html" title="7.1. string — Common string operations"
 
213
             >next</a> |</li>
 
214
        <li class="right" >
 
215
          <a href="exceptions.html" title="6. Built-in Exceptions"
 
216
             >previous</a> |</li>
 
217
        <li><img src="../_static/py.png" alt=""
 
218
                 style="vertical-align: middle; margin-top: -1px"/></li>
 
219
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
 
220
        <li>
 
221
          <span class="version_switcher_placeholder">2.7.11</span>
 
222
          <a href="../index.html">Documentation</a> &raquo;
 
223
        </li>
 
224
 
 
225
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li> 
 
226
      </ul>
 
227
    </div>  
 
228
    <div class="footer">
 
229
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
 
230
    <br />
 
231
    The Python Software Foundation is a non-profit corporation.
 
232
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
 
233
    <br />
 
234
    Last updated on Feb 07, 2016.
 
235
    <a href="../bugs.html">Found a bug</a>?
 
236
    <br />
 
237
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
 
238
    </div>
 
239
 
 
240
  </body>
 
241
</html>
 
 
b'\\ No newline at end of file'