Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / string-methods.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="typesseq-strings.html" />
<link rel="prev" href="typesseq.html" />
<link rel="parent" href="typesseq.html" />
<link rel="next" href="typesseq-strings.html" />
<meta name='aesop' content='information' />
<title>2.3.6.1 String Methods </title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="2.3.6 Sequence Types "
href="typesseq.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="2.3.6 Sequence Types "
href="typesseq.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="2.3.6.2 String Formatting Operations"
href="typesseq-strings.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="typesseq.html">2.3.6 Sequence Types </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="typesseq.html">2.3.6 Sequence Types </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="typesseq-strings.html">2.3.6.2 String Formatting Operations</A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION004361000000000000000"></A><A NAME="string-methods"></A>
<BR>
2.3.6.1 String Methods
</H3>
<P>
These are the string methods which both 8-bit strings and Unicode
objects support:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-176' xml:id='l2h-176' class="method">capitalize</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with only its first character capitalized.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-177' xml:id='l2h-177' class="method">center</tt></b>(</nobr></td>
<td><var>width</var><big>[</big><var>, fillchar</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return centered in a string of length <var>width</var>. Padding is done
using the specified <var>fillchar</var> (default is a space).
<span class="versionnote">Changed in version 2.4:
Support for the <var>fillchar</var> argument.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-178' xml:id='l2h-178' class="method">count</tt></b>(</nobr></td>
<td><var>sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the number of occurrences of substring <var>sub</var> in string
S<code>[<var>start</var>:<var>end</var>]</code>. Optional arguments <var>start</var> and
<var>end</var> are interpreted as in slice notation.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-179' xml:id='l2h-179' class="method">decode</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>encoding</var><big>[</big><var>, errors</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Decodes the string using the codec registered for <var>encoding</var>.
<var>encoding</var> defaults to the default string encoding. <var>errors</var>
may be given to set a different error handling scheme. The default is
<code>'strict'</code>, meaning that encoding errors raise
<tt class="exception">UnicodeError</tt>. Other possible values are <code>'ignore'</code>,
<code>'replace'</code> and any other name registered via
<tt class="function">codecs.register_error</tt>.
<span class="versionnote">New in version 2.2.</span>
<span class="versionnote">Changed in version 2.3:
Support for other error handling schemes added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-180' xml:id='l2h-180' class="method">encode</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>encoding</var><big>[</big><var>,errors</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return an encoded version of the string. Default encoding is the current
default string encoding. <var>errors</var> may be given to set a different
error handling scheme. The default for <var>errors</var> is
<code>'strict'</code>, meaning that encoding errors raise a
<tt class="exception">UnicodeError</tt>. Other possible values are <code>'ignore'</code>,
<code>'replace'</code>, <code>'xmlcharrefreplace'</code>, <code>'backslashreplace'</code>
and any other name registered via <tt class="function">codecs.register_error</tt>.
For a list of possible encodings, see section&nbsp;<A href="standard-encodings.html#standard-encodings">4.9.2</A>.
<span class="versionnote">New in version 2.0.</span>
<span class="versionnote">Changed in version 2.3:
Support for <code>'xmlcharrefreplace'</code> and
<code>'backslashreplace'</code> and other error handling schemes added.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-181' xml:id='l2h-181' class="method">endswith</tt></b>(</nobr></td>
<td><var>suffix</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return <code>True</code> if the string ends with the specified <var>suffix</var>,
otherwise return <code>False</code>. With optional <var>start</var>, test beginning at
that position. With optional <var>end</var>, stop comparing at that position.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-182' xml:id='l2h-182' class="method">expandtabs</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>tabsize</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string where all tab characters are expanded
using spaces. If <var>tabsize</var> is not given, a tab size of <code>8</code>
characters is assumed.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-183' xml:id='l2h-183' class="method">find</tt></b>(</nobr></td>
<td><var>sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the lowest index in the string where substring <var>sub</var> is
found, such that <var>sub</var> is contained in the range [<var>start</var>,
<var>end</var>). Optional arguments <var>start</var> and <var>end</var> are
interpreted as in slice notation. Return <code>-1</code> if <var>sub</var> is
not found.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-184' xml:id='l2h-184' class="method">index</tt></b>(</nobr></td>
<td><var>sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Like <tt class="method">find()</tt>, but raise <tt class="exception">ValueError</tt> when the
substring is not found.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-185' xml:id='l2h-185' class="method">isalnum</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return true if all characters in the string are alphanumeric and there
is at least one character, false otherwise.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-186' xml:id='l2h-186' class="method">isalpha</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return true if all characters in the string are alphabetic and there
is at least one character, false otherwise.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-187' xml:id='l2h-187' class="method">isdigit</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return true if all characters in the string are digits and there
is at least one character, false otherwise.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-188' xml:id='l2h-188' class="method">islower</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return true if all cased characters in the string are lowercase and
there is at least one cased character, false otherwise.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-189' xml:id='l2h-189' class="method">isspace</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return true if there are only whitespace characters in the string and
there is at least one character, false otherwise.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-190' xml:id='l2h-190' class="method">istitle</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return true if the string is a titlecased string and there is at least one
character, for example uppercase characters may only follow uncased
characters and lowercase characters only cased ones. Return false
otherwise.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-191' xml:id='l2h-191' class="method">isupper</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return true if all cased characters in the string are uppercase and
there is at least one cased character, false otherwise.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-192' xml:id='l2h-192' class="method">join</tt></b>(</nobr></td>
<td><var>seq</var>)</td></tr></table></dt>
<dd>
Return a string which is the concatenation of the strings in the
sequence <var>seq</var>. The separator between elements is the string
providing this method.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-193' xml:id='l2h-193' class="method">ljust</tt></b>(</nobr></td>
<td><var>width</var><big>[</big><var>, fillchar</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the string left justified in a string of length <var>width</var>.
Padding is done using the specified <var>fillchar</var> (default is a
space). The original string is returned if
<var>width</var> is less than <code>len(<var>s</var>)</code>.
<span class="versionnote">Changed in version 2.4:
Support for the <var>fillchar</var> argument.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-194' xml:id='l2h-194' class="method">lower</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string converted to lowercase.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-195' xml:id='l2h-195' class="method">lstrip</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>chars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with leading characters removed. The
<var>chars</var> argument is a string specifying the set of characters
to be removed. If omitted or <code>None</code>, the <var>chars</var> argument
defaults to removing whitespace. The <var>chars</var> argument is not
a prefix; rather, all combinations of its values are stripped:
<div class="verbatim"><pre>
&gt;&gt;&gt; ' spacious '.lstrip()
'spacious '
&gt;&gt;&gt; 'www.example.com'.lstrip('cmowz.')
'example.com'
</pre></div>
<span class="versionnote">Changed in version 2.2.2:
Support for the <var>chars</var> argument.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-196' xml:id='l2h-196' class="method">replace</tt></b>(</nobr></td>
<td><var>old, new</var><big>[</big><var>, count</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with all occurrences of substring
<var>old</var> replaced by <var>new</var>. If the optional argument
<var>count</var> is given, only the first <var>count</var> occurrences are
replaced.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-197' xml:id='l2h-197' class="method">rfind</tt></b>(</nobr></td>
<td><var>sub </var><big>[</big><var>,start </var><big>[</big><var>,end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the highest index in the string where substring <var>sub</var> is
found, such that <var>sub</var> is contained within s[start,end]. Optional
arguments <var>start</var> and <var>end</var> are interpreted as in slice
notation. Return <code>-1</code> on failure.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-198' xml:id='l2h-198' class="method">rindex</tt></b>(</nobr></td>
<td><var>sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Like <tt class="method">rfind()</tt> but raises <tt class="exception">ValueError</tt> when the
substring <var>sub</var> is not found.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-199' xml:id='l2h-199' class="method">rjust</tt></b>(</nobr></td>
<td><var>width</var><big>[</big><var>, fillchar</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return the string right justified in a string of length <var>width</var>.
Padding is done using the specified <var>fillchar</var> (default is a space).
The original string is returned if
<var>width</var> is less than <code>len(<var>s</var>)</code>.
<span class="versionnote">Changed in version 2.4:
Support for the <var>fillchar</var> argument.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-200' xml:id='l2h-200' class="method">rsplit</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>sep </var><big>[</big><var>,maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a list of the words in the string, using <var>sep</var> as the
delimiter string. If <var>maxsplit</var> is given, at most <var>maxsplit</var>
splits are done, the <em>rightmost</em> ones. If <var>sep</var> is not specified
or <code>None</code>, any whitespace string is a separator. Except for splitting
from the right, <tt class="method">rsplit()</tt> behaves like <tt class="method">split()</tt> which
is described in detail below.
<span class="versionnote">New in version 2.4.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-201' xml:id='l2h-201' class="method">rstrip</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>chars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with trailing characters removed. The
<var>chars</var> argument is a string specifying the set of characters
to be removed. If omitted or <code>None</code>, the <var>chars</var> argument
defaults to removing whitespace. The <var>chars</var> argument is not
a suffix; rather, all combinations of its values are stripped:
<div class="verbatim"><pre>
&gt;&gt;&gt; ' spacious '.rstrip()
' spacious'
&gt;&gt;&gt; 'mississippi'.rstrip('ipz')
'mississ'
</pre></div>
<span class="versionnote">Changed in version 2.2.2:
Support for the <var>chars</var> argument.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-202' xml:id='l2h-202' class="method">split</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>sep </var><big>[</big><var>,maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a list of the words in the string, using <var>sep</var> as the
delimiter string. If <var>maxsplit</var> is given, at most <var>maxsplit</var>
splits are done. (thus, the list will have at most <code><var>maxsplit</var>+1</code>
elements). If <var>maxsplit</var> is not specified, then there
is no limit on the number of splits (all possible splits are made).
Consecutive delimiters are not grouped together and are
deemed to delimit empty strings (for example, "<tt class="samp">'1,,2'.split(',')</tt>"returns "<tt class="samp">['1', '', '2']</tt>"). The <var>sep</var> argument may consist of
multiple characters (for example, "<tt class="samp">'1, 2, 3'.split(', ')</tt>" returns
"<tt class="samp">['1', '2', '3']</tt>"). Splitting an empty string with a specified
separator returns "<tt class="samp">['']</tt>".
<P>
If <var>sep</var> is not specified or is <code>None</code>, a different splitting
algorithm is applied. First, whitespace characters (spaces, tabs,
newlines, returns, and formfeeds) are stripped from both ends. Then,
words are separated by arbitrary length strings of whitespace
characters. Consecutive whitespace delimiters are treated as a single
delimiter ("<tt class="samp">'1 2 3'.split()</tt>" returns "<tt class="samp">['1', '2', '3']</tt>").
Splitting an empty string or a string consisting of just whitespace
returns an empty list.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-203' xml:id='l2h-203' class="method">splitlines</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>keepends</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a list of the lines in the string, breaking at line
boundaries. Line breaks are not included in the resulting list unless
<var>keepends</var> is given and true.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-204' xml:id='l2h-204' class="method">startswith</tt></b>(</nobr></td>
<td><var>prefix</var><big>[</big><var>,
start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return <code>True</code> if string starts with the <var>prefix</var>, otherwise
return <code>False</code>. With optional <var>start</var>, test string beginning at
that position. With optional <var>end</var>, stop comparing string at that
position.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-205' xml:id='l2h-205' class="method">strip</tt></b>(</nobr></td>
<td><var></var><big>[</big><var>chars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with the leading and trailing characters
removed. The <var>chars</var> argument is a string specifying the set of
characters to be removed. If omitted or <code>None</code>, the <var>chars</var>
argument defaults to removing whitespace. The <var>chars</var> argument is not
a prefix or suffix; rather, all combinations of its values are stripped:
<div class="verbatim"><pre>
&gt;&gt;&gt; ' spacious '.strip()
'spacious'
&gt;&gt;&gt; 'www.example.com'.strip('cmowz.')
'example'
</pre></div>
<span class="versionnote">Changed in version 2.2.2:
Support for the <var>chars</var> argument.</span>
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-206' xml:id='l2h-206' class="method">swapcase</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string with uppercase characters converted to
lowercase and vice versa.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-207' xml:id='l2h-207' class="method">title</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a titlecased version of the string: words start with uppercase
characters, all remaining cased characters are lowercase.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-208' xml:id='l2h-208' class="method">translate</tt></b>(</nobr></td>
<td><var>table</var><big>[</big><var>, deletechars</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string where all characters occurring in the
optional argument <var>deletechars</var> are removed, and the remaining
characters have been mapped through the given translation table, which
must be a string of length 256.
<P>
For Unicode objects, the <tt class="method">translate()</tt> method does not
accept the optional <var>deletechars</var> argument. Instead, it
returns a copy of the <var>s</var> where all characters have been mapped
through the given translation table which must be a mapping of
Unicode ordinals to Unicode ordinals, Unicode strings or <code>None</code>.
Unmapped characters are left untouched. Characters mapped to <code>None</code>
are deleted. Note, a more flexible approach is to create a custom
character mapping codec using the <tt class="module"><a href="module-codecs.html">codecs</a></tt> module (see
<tt class="module">encodings.cp1251</tt> for an example).
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-209' xml:id='l2h-209' class="method">upper</tt></b>(</nobr></td>
<td><var></var>)</td></tr></table></dt>
<dd>
Return a copy of the string converted to uppercase.
<P>
For 8-bit strings, this method is locale-dependent.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-210' xml:id='l2h-210' class="method">zfill</tt></b>(</nobr></td>
<td><var>width</var>)</td></tr></table></dt>
<dd>
Return the numeric string left filled with zeros in a string
of length <var>width</var>. The original string is returned if
<var>width</var> is less than <code>len(<var>s</var>)</code>.
<span class="versionnote">New in version 2.2.2.</span>
</dl>
<P>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="2.3.6 Sequence Types "
href="typesseq.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="2.3.6 Sequence Types "
href="typesseq.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="2.3.6.2 String Formatting Operations"
href="typesseq-strings.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="typesseq.html">2.3.6 Sequence Types </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="typesseq.html">2.3.6 Sequence Types </A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="typesseq-strings.html">2.3.6.2 String Formatting Operations</A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>