1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: module string</title>
<style type="text/css"><!--
TT { font-family: lucidatypewriter, lucida console, courier }
--></style></head><body bgcolor="#f0f0f8">
<table width="100%" cellspacing=0 cellpadding=2 border=0>
<tr bgcolor="#7799ee">
<td valign=bottom><small> <br></small
><font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>string</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:///C|/python21/lib/string.py">c:\python21\lib\string.py</a></font></td></tr></table>
<p><small><tt>A collection of string operations (most are no longer used in Python 1.6).<br>
<br>
Warning: most of the code you see here isn't normally used nowadays. With<br>
Python 1.6, many of these functions are implemented as methods on the<br>
standard string object. They used to be implemented by a built-in module<br>
called strop, but strop is now obsolete itself.<br>
<br>
Public module variables:<br>
<br>
whitespace -- a string containing all characters considered whitespace<br>
lowercase -- a string containing all characters considered lowercase letters<br>
uppercase -- a string containing all characters considered uppercase letters<br>
letters -- a string containing all characters considered letters<br>
digits -- a string containing all characters considered decimal digits<br>
hexdigits -- a string containing all characters considered hexadecimal digits<br>
octdigits -- a string containing all characters considered octal digits<br>
punctuation -- a string containing all characters considered punctuation<br>
printable -- a string containing all characters considered printable</tt></small></p>
<p><table width="100%" cellspacing=0 cellpadding=2 border=0>
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom><small><small> <br></small></small
><font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-_float"><strong>_float</strong></a> = float(...)<dd><small><tt>float(x) -> floating point number<br>
<br>
Convert a string or number to a floating point number, if possible.</tt></small></dl>
<dl><dt><a name="-_int"><strong>_int</strong></a> = int(...)<dd><small><tt>int(x[, base]) -> integer<br>
<br>
Convert a string or number to an integer, if possible. A floating point<br>
argument will be truncated towards zero (this does not include a string<br>
representation of a floating point number!) When converting a string, use<br>
the optional base. It is an error to supply a base when converting a<br>
non-string.</tt></small></dl>
<dl><dt><a name="-_long"><strong>_long</strong></a> = long(...)<dd><small><tt>long(x) -> long integer<br>
long(x, base) -> long integer<br>
<br>
Convert a string or number to a long integer, if possible. A floating<br>
point argument will be truncated towards zero (this does not include a<br>
string representation of a floating point number!) When converting a<br>
string, use the given base. It is an error to supply a base when<br>
converting a non-string.</tt></small></dl>
<dl><dt><a name="-atof"><strong>atof</strong></a>(s)<dd><small><tt><a href="#-atof">atof</a>(s) -> float<br>
<br>
Return the floating point number represented by the string s.</tt></small></dl>
<dl><dt><a name="-atoi"><strong>atoi</strong></a>(s, base<small><font color="#909090">=10</font></small>)<dd><small><tt><a href="#-atoi">atoi</a>(s [,base]) -> int<br>
<br>
Return the integer represented by the string s in the given<br>
base, which defaults to 10. The string s must consist of one<br>
or more digits, possibly preceded by a sign. If base is 0, it<br>
is chosen from the leading characters of s, 0 for octal, 0x or<br>
0X for hexadecimal. If base is 16, a preceding 0x or 0X is<br>
accepted.</tt></small></dl>
<dl><dt><a name="-atol"><strong>atol</strong></a>(s, base<small><font color="#909090">=10</font></small>)<dd><small><tt><a href="#-atol">atol</a>(s [,base]) -> long<br>
<br>
Return the long integer represented by the string s in the<br>
given base, which defaults to 10. The string s must consist<br>
of one or more digits, possibly preceded by a sign. If base<br>
is 0, it is chosen from the leading characters of s, 0 for<br>
octal, 0x or 0X for hexadecimal. If base is 16, a preceding<br>
0x or 0X is accepted. A trailing L or l is not accepted,<br>
unless base is 0.</tt></small></dl>
<dl><dt><a name="-capitalize"><strong>capitalize</strong></a>(s)<dd><small><tt><a href="#-capitalize">capitalize</a>(s) -> string<br>
<br>
Return a copy of the string s with only its first character<br>
capitalized.</tt></small></dl>
<dl><dt><a name="-capwords"><strong>capwords</strong></a>(s, sep<small><font color="#909090">=None</font></small>)<dd><small><tt><a href="#-capwords">capwords</a>(s, [sep]) -> string<br>
<br>
Split the argument into words using split, capitalize each<br>
word using capitalize, and join the capitalized words using<br>
join. Note that this replaces runs of whitespace characters by<br>
a single space.</tt></small></dl>
<dl><dt><a name="-center"><strong>center</strong></a>(s, width)<dd><small><tt><a href="#-center">center</a>(s, width) -> string<br>
<br>
Return a center version of s, in a field of the specified<br>
width. padded with spaces as needed. The string is never<br>
truncated.</tt></small></dl>
<dl><dt><a name="-count"><strong>count</strong></a>(s, *args)<dd><small><tt><a href="#-count">count</a>(s, sub[, start[,end]]) -> int<br>
<br>
Return the number of occurrences of substring sub in string<br>
s[start:end]. Optional arguments start and end are<br>
interpreted as in slice notation.</tt></small></dl>
<dl><dt><a name="-expandtabs"><strong>expandtabs</strong></a>(s, tabsize<small><font color="#909090">=8</font></small>)<dd><small><tt><a href="#-expandtabs">expandtabs</a>(s [,tabsize]) -> string<br>
<br>
Return a copy of the string s with all tab characters replaced<br>
by the appropriate number of spaces, depending on the current<br>
column, and the tabsize (default 8).</tt></small></dl>
<dl><dt><a name="-find"><strong>find</strong></a>(s, *args)<dd><small><tt><a href="#-find">find</a>(s, sub [,start [,end]]) -> in<br>
<br>
Return the lowest index in s where substring sub is found,<br>
such that sub is contained within s[start,end]. Optional<br>
arguments start and end are interpreted as in slice notation.<br>
<br>
Return -1 on failure.</tt></small></dl>
<dl><dt><a name="-index"><strong>index</strong></a>(s, *args)<dd><small><tt><a href="#-index">index</a>(s, sub [,start [,end]]) -> int<br>
<br>
Like find but raises ValueError when the substring is not found.</tt></small></dl>
<dl><dt><a name="-join"><strong>join</strong></a>(words, sep<small><font color="#909090">=' '</font></small>)<dd><small><tt><a href="#-join">join</a>(list [,sep]) -> string<br>
<br>
Return a string composed of the words in list, with<br>
intervening occurrences of sep. The default separator is a<br>
single space.<br>
<br>
(joinfields and join are synonymous)</tt></small></dl>
<dl><dt><a name="-joinfields"><strong>joinfields</strong></a> = join(words, sep<small><font color="#909090">=' '</font></small>)<dd><small><tt><a href="#-join">join</a>(list [,sep]) -> string<br>
<br>
Return a string composed of the words in list, with<br>
intervening occurrences of sep. The default separator is a<br>
single space.<br>
<br>
(joinfields and join are synonymous)</tt></small></dl>
<dl><dt><a name="-ljust"><strong>ljust</strong></a>(s, width)<dd><small><tt><a href="#-ljust">ljust</a>(s, width) -> string<br>
<br>
Return a left-justified version of s, in a field of the<br>
specified width, padded with spaces as needed. The string is<br>
never truncated.</tt></small></dl>
<dl><dt><a name="-lower"><strong>lower</strong></a>(s)<dd><small><tt><a href="#-lower">lower</a>(s) -> string<br>
<br>
Return a copy of the string s converted to lowercase.</tt></small></dl>
<dl><dt><a name="-lstrip"><strong>lstrip</strong></a>(s)<dd><small><tt><a href="#-lstrip">lstrip</a>(s) -> string<br>
<br>
Return a copy of the string s with leading whitespace removed.</tt></small></dl>
<dl><dt><a name="-maketrans"><strong>maketrans</strong></a>(...)<dd><small><tt><a href="#-maketrans">maketrans</a>(frm, to) -> string<br>
<br>
Return a translation table (a string of 256 bytes long)<br>
suitable for use in string.translate. The strings frm and to<br>
must be of the same length.</tt></small></dl>
<dl><dt><a name="-replace"><strong>replace</strong></a>(s, old, new, maxsplit<small><font color="#909090">=-1</font></small>)<dd><small><tt>replace (str, old, new[, maxsplit]) -> string<br>
<br>
Return a copy of string str with all occurrences of substring<br>
old replaced by new. If the optional argument maxsplit is<br>
given, only the first maxsplit occurrences are replaced.</tt></small></dl>
<dl><dt><a name="-rfind"><strong>rfind</strong></a>(s, *args)<dd><small><tt><a href="#-rfind">rfind</a>(s, sub [,start [,end]]) -> int<br>
<br>
Return the highest index in s where substring sub is found,<br>
such that sub is contained within s[start,end]. Optional<br>
arguments start and end are interpreted as in slice notation.<br>
<br>
Return -1 on failure.</tt></small></dl>
<dl><dt><a name="-rindex"><strong>rindex</strong></a>(s, *args)<dd><small><tt><a href="#-rindex">rindex</a>(s, sub [,start [,end]]) -> int<br>
<br>
Like rfind but raises ValueError when the substring is not found.</tt></small></dl>
<dl><dt><a name="-rjust"><strong>rjust</strong></a>(s, width)<dd><small><tt><a href="#-rjust">rjust</a>(s, width) -> string<br>
<br>
Return a right-justified version of s, in a field of the<br>
specified width, padded with spaces as needed. The string is<br>
never truncated.</tt></small></dl>
<dl><dt><a name="-rstrip"><strong>rstrip</strong></a>(s)<dd><small><tt><a href="#-rstrip">rstrip</a>(s) -> string<br>
<br>
Return a copy of the string s with trailing whitespace<br>
removed.</tt></small></dl>
<dl><dt><a name="-split"><strong>split</strong></a>(s, sep<small><font color="#909090">=None</font></small>, maxsplit<small><font color="#909090">=-1</font></small>)<dd><small><tt><a href="#-split">split</a>(s [,sep [,maxsplit]]) -> list of strings<br>
<br>
Return a list of the words in the string s, using sep as the<br>
delimiter string. If maxsplit is given, splits into at most<br>
maxsplit words. If sep is not specified, any whitespace string<br>
is a separator.<br>
<br>
(split and splitfields are synonymous)</tt></small></dl>
<dl><dt><a name="-splitfields"><strong>splitfields</strong></a> = split(s, sep<small><font color="#909090">=None</font></small>, maxsplit<small><font color="#909090">=-1</font></small>)<dd><small><tt><a href="#-split">split</a>(s [,sep [,maxsplit]]) -> list of strings<br>
<br>
Return a list of the words in the string s, using sep as the<br>
delimiter string. If maxsplit is given, splits into at most<br>
maxsplit words. If sep is not specified, any whitespace string<br>
is a separator.<br>
<br>
(split and splitfields are synonymous)</tt></small></dl>
<dl><dt><a name="-strip"><strong>strip</strong></a>(s)<dd><small><tt><a href="#-strip">strip</a>(s) -> string<br>
<br>
Return a copy of the string s with leading and trailing<br>
whitespace removed.</tt></small></dl>
<dl><dt><a name="-swapcase"><strong>swapcase</strong></a>(s)<dd><small><tt><a href="#-swapcase">swapcase</a>(s) -> string<br>
<br>
Return a copy of the string s with upper case characters<br>
converted to lowercase and vice versa.</tt></small></dl>
<dl><dt><a name="-translate"><strong>translate</strong></a>(s, table, deletions<small><font color="#909090">=''</font></small>)<dd><small><tt><a href="#-translate">translate</a>(s,table [,deletions]) -> string<br>
<br>
Return a copy of the string s, where all characters occurring<br>
in the optional argument deletions are removed, and the<br>
remaining characters have been mapped through the given<br>
translation table, which must be a string of length 256. The<br>
deletions argument is not allowed for Unicode strings.</tt></small></dl>
<dl><dt><a name="-upper"><strong>upper</strong></a>(s)<dd><small><tt><a href="#-upper">upper</a>(s) -> string<br>
<br>
Return a copy of the string s converted to uppercase.</tt></small></dl>
<dl><dt><a name="-zfill"><strong>zfill</strong></a>(x, width)<dd><small><tt><a href="#-zfill">zfill</a>(x, width) -> string<br>
<br>
Pad a numeric string x with zeros on the left, to fill a field<br>
of the specified width. The string x is never truncated.</tt></small></dl>
</td></tr></table>
<p><table width="100%" cellspacing=0 cellpadding=2 border=0>
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom><small><small> <br></small></small
><font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>_StringType</strong> = <type 'string'><br>
<strong>__file__</strong> = r'c:\Python21\Lib\string.pyc'<br>
<strong>__name__</strong> = 'string'<br>
<strong>_idmap</strong> = '<font color="#c040c0">\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f</font> !"#$%&<font color="#c040c0">\'</font>()*+,-./...<font color="#c040c0">\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff</font>'<br>
<strong>_idmapL</strong> = None<br>
<strong>digits</strong> = '0123456789'<br>
<strong>hexdigits</strong> = '0123456789abcdefABCDEF'<br>
<strong>letters</strong> = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'<br>
<strong>lowercase</strong> = 'abcdefghijklmnopqrstuvwxyz'<br>
<strong>octdigits</strong> = '01234567'<br>
<strong>printable</strong> = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&<font color="#c040c0">\'</font>()*+,-./:;<=>?@[<font color="#c040c0">\\</font>]^_`{|}~ <font color="#c040c0">\t\n\r\x0b\x0c</font>'<br>
<strong>punctuation</strong> = '!"#$%&<font color="#c040c0">\'</font>()*+,-./:;<=>?@[<font color="#c040c0">\\</font>]^_`{|}~'<br>
<strong>uppercase</strong> = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'<br>
<strong>whitespace</strong> = '<font color="#c040c0">\t\n\x0b\x0c\r</font> '</td></tr></table>
</body></html>
|