<divclass="children"><h1>Strings</h1><divclass="text">These methods are available on both regular and Unicode strings.</div><divclass="definition"><aname="_capitalize">.capitalize() <divclass="children"><divclass="exclamation"><strong>Important:</strong> For regular strings, this method depends on the currently configured locale to decide what is 'lowercase' and what is 'uppercase'. <divclass="children"></div></div><divclass="text">Returns a copy of the string with the first character capitalized, and the rest of the characters lowercased.</div></div></a></div><divclass="definition"><aname="_centerwidthfillchar">.center(<spanclass="fixed">width</span>[, <spanclass="fixed">fillchar</span>]) <divclass="children"><divclass="text">Returns a copy of the string, centered by padding it with the fill character on both sides until the given width is reached.</div><dl><dt>width</dt><dd>The desired width of the final string.<divclass="children"></div></dd></dl><dl><dt>fillchar</dt><dd><em>Optional.</em> The character to use as a fill character. This is a space character by default.<divclass="children"></div></dd></dl></div></a></div><divclass="definition"><aname="_countsubstartend">.count(<spanclass="fixed">sub</span>[, <spanclass="fixed">start</span>[, <spanclass="fixed">end</span>]]) <divclass="children"><divclass="text">Returns the number of non-overlapping occurrences of the given substring in the given range.</div><dl><dt>sub</dt><dd>The substring to search for.<divclass="children"></div></dd></dl><dl><dt>start</dt><dd><em>Optional.</em> The starting point for the search. Interpreted as in slice notation. Defaults to the start of the string.<divclass="children"></div></dd></dl><dl><dt>end</dt><dd><em>Optional.</em> The end point for the search. Interpreted as in slice notation. Defaults to the end of the string.<divclass="children"></div></dd></dl></div></a></div><divclass="definition"><aname="_decodeencodingerrors">.decode([<spanclass="fixed">encoding</span>[, <spanclass="fixed">errors</span>]]) <divclass="children"><divclass="text">Returns a <spanclass="fixed">unicode</span> string containing a copy of the original string, decoded using the codec registered for the specified encoding.</div><divclass="text"><strong>Since Python 2.7:</strong> You can also specify the arguments to this method as keyword arguments, for clarity.</div><dl><dt>encoding</dt><dd><em>Optional.</em> The encoding that the string is currently in. If not specified, the value from <ahref="sys.html"><spanclass="fixed">sys.getdefaultencoding</span></a> is used.<divclass="children"></div></dd></dl><dl><dt>errors</dt><dd><em>Optional.</em> The error handling scheme to use. Can be any of the following values, or any other name that is registered through <ahref="codecs.html"><spanclass="fixed">codecs.register_error</span></a>.<divclass="children"><dl><dt>strict</dt><dd>This is the default. Encoding errors raise a <spanclass="fixed">UnicodeError</span> exception, or a subclass thereof.<divclass="children"></div></dd></dl><dl><dt>ignore</dt><dd>When an error is encountered, ignore the character, and move on to the next one.<divclass="children"></div></dd></dl><dl><dt>replace</dt><dd>When an error is encountered, replace the problematic character with U+FFFD, for the built-in Unicode codecs.<divclass="children"></div></dd></dl></div></dd></dl></div></a></div><divclass="definition"><aname="_encodeencodingerrors">.encode([<spanclass="fixed">encoding</span>[, <spanclass="fixed">errors</span>]]) <divclass="children"><divclass="text">Returns a regular string containing a copy of the original string, encoded using the codec registered for the specified encoding.</div><divclass="text"><strong>Since Python 2.7:</strong> You can also specify the arguments to this method as keyword arguments, for clarity.</div><dl><dt>encoding</dt><dd><em>Optional.</em> The encoding you wish to encode the string to. If not specified, the value from <ahref="sys.html"><spanclass="fixed">sys.getdefaultencoding</span></a> is used.