A collection of string operations (most are no longer used).
Warning: most of the code you see here isn't normally used nowadays.
Beginning with Python 1.6, many of these functions are implemented as
methods on the standard string object. They used to be implemented by a
built-in module called strop, but strop is now obsolete itself.
whitespace -- a string containing all characters considered whitespace
lowercase -- a string containing all characters considered lowercase
letters uppercase -- a string containing all characters considered
uppercase letters letters -- a string containing all characters
considered letters digits -- a string containing all characters
considered decimal digits hexdigits -- a string containing all characters
considered hexadecimal digits octdigits -- a string containing all
characters considered octal digits punctuation -- a string containing all
characters considered punctuation printable -- a string containing all
characters considered printable
float
|
atof(s)
Return the floating point number represented by the string s. |
source code
|
|
int
|
atoi(s,
base=...)
Return the integer represented by the string s in the given base,
which defaults to 10. |
source code
|
|
long
|
atol(s,
base=...)
Return the long integer represented by the string s in the given
base, which defaults to 10. |
source code
|
|
string
|
capitalize(s)
Return a copy of the string s with only its first character
capitalized. |
source code
|
|
string
|
capwords(s,
sep=...)
Split the argument into words using split, capitalize each word using
capitalize, and join the capitalized words using join. |
source code
|
|
string
|
center(s,
width,
fillchar=...)
Return a center version of s, in a field of the specified width. |
source code
|
|
int
|
count(s,
sub,
start=...,
end=...)
Return the number of occurrences of substring sub in string
s[start:end]. |
source code
|
|
string
|
expandtabs(s,
tabsize=...)
Return a copy of the string s with all tab characters replaced by the
appropriate number of spaces, depending on the current column, and
the tabsize (default 8). |
source code
|
|
in
|
find(s,
sub,
start=... ,
end=...)
Return the lowest index in s where substring sub is found, such that
sub is contained within s[start,end]. |
source code
|
|
int
|
index(s,
sub,
start=... ,
end=...)
Like find but raises ValueError when the substring is not found. |
source code
|
|
string
|
join(list,
sep=...)
Return a string composed of the words in list, with intervening
occurrences of sep. |
source code
|
|
string
|
joinfields(list,
sep=...)
Return a string composed of the words in list, with intervening
occurrences of sep. |
source code
|
|
string
|
ljust(s,
width,
fillchar=...)
Return a left-justified version of s, in a field of the specified
width, padded with spaces as needed. |
source code
|
|
string
|
lower(s)
Return a copy of the string s converted to lowercase. |
source code
|
|
string
|
lstrip(s,
chars=...)
Return a copy of the string s with leading whitespace removed. |
source code
|
|
|
replace(s,
old,
new,
maxreplace=-1)
replace (str, old, new[, maxreplace]) -> string |
source code
|
|
int
|
rfind(s,
sub,
start=... ,
end=...)
Return the highest index in s where substring sub is found, such that
sub is contained within s[start,end]. |
source code
|
|
int
|
rindex(s,
sub,
start=... ,
end=...)
Like rfind but raises ValueError when the substring is not found. |
source code
|
|
string
|
rjust(s,
width,
fillchar=...)
Return a right-justified version of s, in a field of the specified
width, padded with spaces as needed. |
source code
|
|
list of strings
|
rsplit(s,
sep=... ,
maxsplit=...)
Return a list of the words in the string s, using sep as the
delimiter string, starting at the end of the string and working to
the front. |
source code
|
|
string
|
rstrip(s,
chars=...)
Return a copy of the string s with trailing whitespace removed. |
source code
|
|
list of strings
|
split(s,
sep=... ,
maxsplit=...)
Return a list of the words in the string s, using sep as the
delimiter string. |
source code
|
|
list of strings
|
splitfields(s,
sep=... ,
maxsplit=...)
Return a list of the words in the string s, using sep as the
delimiter string. |
source code
|
|
string
|
strip(s,
chars=...)
Return a copy of the string s with leading and trailing whitespace
removed. |
source code
|
|
string
|
swapcase(s)
Return a copy of the string s with upper case characters converted to
lowercase and vice versa. |
source code
|
|
string
|
translate(s,
table,
deletions=...)
Return a copy of the string s, where all characters occurring in the
optional argument deletions are removed, and the remaining characters
have been mapped through the given translation table, which must be a
string of length 256. |
source code
|
|
string
|
upper(s)
Return a copy of the string s converted to uppercase. |
source code
|
|
string
|
zfill(x,
width)
Pad a numeric string x with zeros on the left, to fill a field of the
specified width. |
source code
|
|
|
__package__ = None
hash(x)
|
|
_idmap = ' \x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x ...
|
|
_idmapL = None
hash(x)
|
|
ascii_letters = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRS ...
|
|
ascii_lowercase = ' abcdefghijklmnopqrstuvwxyz '
|
|
ascii_uppercase = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ '
|
|
digits = ' 0123456789 '
|
|
hexdigits = ' 0123456789abcdefABCDEF '
|
|
letters = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
|
|
lowercase = ' abcdefghijklmnopqrstuvwxyz '
|
|
octdigits = ' 01234567 '
|
|
printable = ' 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLM ...
|
|
punctuation = ' !"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ '
|
|
uppercase = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ '
|
|
whitespace = ' \t\n\x0b\x0c\r '
|