Help on module string:
帮助模块的字符串:
NAME
的名字
string - A collection of string operations (most are no longer used).
字符串,字符串操作的集合(大多数是不再使用)。
DESCRIPTION
描述
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
从Python 1.6开始,许多这些功能实现的
methods on the standard string object. They used to be implemented by
方法标准字符串对象。他们使用来实现
a built-in module called strop, but strop is now obsolete itself.
一个内置的模块称为磨,但磨现在过时了。
Public module variables:
公共模块变量:
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
hexdigits——一个字符串包含所有字符视为十六进制数字
octdigits -- a string containing all characters considered octal digits
octdigits——一个字符串包含所有字符视为八进制数字
punctuation -- a string containing all characters considered punctuation
标点符号——一个字符串包含所有字符标点符号
printable -- a string containing all characters considered printable
可打印——一个包含所有字符视为可打印字符串
CLASSES
类
__builtin__.object
__builtin__.object
Formatter
格式化程序
Template
模板
class Formatter(__builtin__.object)
Formatter类(__builtin__.object)
| Methods defined here:
|这里定义方法:
|
|
| check_unused_args(self, used_args, args, kwargs)
| check_unused_args(自我、used_args args,kwargs)
|
|
| convert_field(self, value, conversion)
| convert_field(自我价值,转换)
|
|
| format(*args, **kwargs)
|格式(* args,* * kwargs)
|
|
| format_field(self, value, format_spec)
| format_field(自我价值,format_spec)
|
|
| get_field(self, field_name, args, kwargs)
| get_field(自我、field_name args,kwargs)
| # given a field_name, find the object it references.
| # field_name,找到它引用的对象。
| # field_name: the field being looked up, e.g. "0.name"
| # field_name:字段被抬起头,如。“0.名称”
| # or "lookup[3]"
| #或“查找”[3]
| # used_args: a set of which args have been used
| # used_args:一组使用arg游戏
| # args, kwargs: as passed in to vformat
| # args,kwargs:vformat传入
|
|
| get_value(self, key, args, kwargs)
| get_value(自我、关键参数、kwargs)
|
|
| parse(self, format_string)
|解析(自我,format_string)
| # returns an iterable that contains tuples of the form:
| #返回一个iterable包含元组的形式:
| # (literal_text, field_name, format_spec, conversion)
| #(literal_text field_name format_spec,转换)
| # literal_text can be zero length
| # literal_text可以零长度
| # field_name can be None, in which case there's no
| # field_name可以没有,在这种情况下没有
| # object to format and output
| #对象格式和输出
| # if field_name is not None, it is looked up, formatted
| #如果field_name不是没有,抬头,格式化
| # with format_spec and conversion and then used
| # format_spec和转换,然后使用
|
|
| vformat(self, format_string, args, kwargs)
| vformat(自我、format_string args,kwargs)
|
|
| ----------------------------------------------------------------------
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Data descriptors defined here:
|数据描述符定义:
|
|
| __dict__
| __dict__
| dictionary for instance variables (if defined)
|字典为实例变量(如果定义)
|
|
| __weakref__
| __weakref__
| list of weak references to the object (if defined)
|对象的弱引用列表(如果定义)
class Template(__builtin__.object)
类模板(__builtin__.object)
| A string class for supporting $-substitutions.
|一个字符串类支持替换美元。
|
|
| Methods defined here:
|这里定义方法:
|
|
| __init__(self, template)
| __init__(自我、模板)
|
|
| safe_substitute(*args, **kws)
| safe_substitute * args,* *(kws)
|
|
| substitute(*args, **kws)
|替代(* args,* * kws)
|
|
| ----------------------------------------------------------------------
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Data descriptors defined here:
|数据描述符定义:
|
|
| __dict__
| __dict__
| dictionary for instance variables (if defined)
|字典为实例变量(如果定义)
|
|
| __weakref__
| __weakref__
| list of weak references to the object (if defined)
|对象的弱引用列表(如果定义)
|
|
| ----------------------------------------------------------------------
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Data and other attributes defined here:
|数据和其他属性的定义:
|
|
| __metaclass__ = <class 'string._TemplateMetaclass'>
| __metaclass__ = <类“string._TemplateMetaclass”>
|
|
|
|
| delimiter = '$'
|分隔符= ' $ '
|
|
| idpattern = '[_a-z][_a-z0-9]*'
| idpattern = '[_a-z][_a-z0-9]*’
|
|
| pattern = <_sre. SRE_Pattern object>
| = < _sre模式。SRE_Pattern对象>
FUNCTIONS
功能
atof(s)
atof(s)
atof(s) -> float
atof(s)- >浮动
Return the floating point number represented by the string s.
返回浮点数表示的字符串。
atoi(s, base=10)
atoi(年代,基地= 10)
atoi(s [,base]) -> int
atoi(s[,])- > int
Return the integer represented by the string s in the given
返回整数代表的字符串在给定的
base, which defaults to 10. The string s must consist of one
基地,默认为10。字符串必须包含一个
or more digits, possibly preceded by a sign. If base is 0, it
或更多的数字,可能之前签署。如果基本为0,它
is chosen from the leading characters of s, 0 for octal, 0x or
选择主要人物的年代,0为八进制,0 x或
0X for hexadecimal. If base is 16, a preceding 0x or 0X is
0 x十六进制。如果基地16个,前的0 x 0 x
accepted.
接受。
atol(s, base=10)
atol(年代,基地= 10)
atol(s [,base]) -> long
atol(s[,])- >长
Return the long integer represented by the string s in the
返回所表示的长整数字符串中
given base, which defaults to 10. The string s must consist
鉴于基地,默认为10。字符串必须由
of one or more digits, possibly preceded by a sign. If base
一个或多个数字,可能之前的迹象。如果基础
is 0, it is chosen from the leading characters of s, 0 for
是0,这是选择从年代的主要人物,0
octal, 0x or 0X for hexadecimal. If base is 16, a preceding
八进制,0 x或者x十六进制。如果基地16日之前
0x or 0X is accepted. A trailing L or l is not accepted,
0 x或者x是接受。落后于L或L不接受,
unless base is 0.
除非基地是0。
capitalize(s)
大写(s)
capitalize(s) -> string
大写(s)- >字符串
Return a copy of the string s with only its first character
返回字符串的副本年代只有它的第一个字符
capitalized.
大写。
capwords(s, sep=None)
capwords(年代,9 =没有)
capwords(s [,sep]) -> string
capwords(s[9])- >字符串
Split the argument into words using split, capitalize each
将参数分为单词使用分割,利用
word using capitalize, and join the capitalized words using
使用大写单词,并加入大写单词使用
join. If the optional second argument sep is absent or None,
加入。如果9月可选的第二个参数是缺失或没有,
runs of whitespace characters are replaced by a single space
空白字符替换为一个空格
and leading and trailing whitespace are removed, otherwise
和前导和尾随空白被删除,否则
sep is used to split and join the words.
9月是用来分割并加入的话。
center(s, width, *args)
中心(年代,宽度,* args)
center(s, width[, fillchar]) -> string
中心(年代,宽度[,fillchar])- >字符串
Return a center version of s, in a field of the specified
返回一个中心版本的年代,在一个指定的领域
width. padded with spaces as needed. The string is never
宽度。根据需要填充的空间。字符串是从来没有
truncated. If specified the fillchar is used instead of spaces.
截断。如果指定了fillchar代替空间。
count(s, *args)
数(年代,* args)
count(s, sub[, start[,end]]) -> int
计数(年代,子,开始[,]])- > int
Return the number of occurrences of substring sub in string
返回的数量出现的子字符串的子字符串
s[start:end]. Optional arguments start and end are
年代开始:结束。可选参数的开始和结束
interpreted as in slice notation.
解释为片符号。
expandtabs(s, tabsize=8)
expandtabs(年代,tabsize = 8)
expandtabs(s [,tabsize]) -> 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).
列,tabsize(默认8)。
find(s, *args)
找到(年代,* args)
find(s, sub [,start [,end]]) -> in
找到(年代,子,开始[,]])- >
Return the lowest index in s where substring sub is found,
回报指数最低的年代找到子字符串的子,
such that sub is contained within s[start,end]. Optional
这样的子是包含在s(开始、结束)。可选
arguments start and end are interpreted as in slice notation.
参数中解释为开始和结束符号。
Return -1 on failure.
失败返回1。
index(s, *args)
指数(s * args)
index(s, sub [,start [,end]]) -> int
指数(s,子,开始[,]])- > int
Like find but raises ValueError when the substring is not found.
像找到但ValueError当没有找到子字符串。
join(words, sep=' ')
加入(话说,9 = ')
join(list [,sep]) -> string
加入(列表[9])- >字符串
Return a string composed of the words in list, with
返回一个字符串组成的单词列表,
intervening occurrences of sep. The default separator is a
干预出现的9月,默认的分隔符是一个
single space.
单一的空间。
(joinfields and join are synonymous)
(同义joinfields并加入)
joinfields = join(words, sep=' ')
joinfields =加入(话说,9 = ')
join(list [,sep]) -> string
加入(列表[9])- >字符串
Return a string composed of the words in list, with
返回一个字符串组成的单词列表,
intervening occurrences of sep. The default separator is a
干预出现的9月,默认的分隔符是一个
single space.
单一的空间。
(joinfields and join are synonymous)
(同义joinfields并加入)
ljust(s, width, *args)
ljust(年代,宽度,* args)
ljust(s, width[, fillchar]) -> string
ljust(年代,宽度[fillchar])- >字符串
Return a left-justified version of s, in a field of the
返回一个左对齐的版本的年代,在一个领域
specified width, padded with spaces as needed. The string is
根据需要指定宽度,填补空间。字符串是
never truncated. If specified the fillchar is used instead of spaces.
从来没有截断。如果指定了fillchar代替空间。
lower(s)
低(s)
lower(s) -> string
低(s)- >字符串
Return a copy of the string s converted to lowercase.
返回的字符串转换为小写。
lstrip(s, chars=None)
lstrip(年代,识字课=没有)
lstrip(s [,chars]) -> string
lstrip(s(字符))- >字符串
Return a copy of the string s with leading whitespace removed.
返回字符串的副本删除前导空白。
If chars is given and not None, remove characters in chars instead.
如果字符而不是没有,删除字符字符代替。
maketrans(...)
maketrans(…)
maketrans(frm, to) -> string
maketrans(,)- >字符串
Return a translation table (a string of 256 bytes long)
返回一个转换表(长256字节的字符串)
suitable for use in string.translate. The strings frm and to
适用于string.translate。纳和字符串
must be of the same length.
必须是相同的长度。
replace(s, old, new, maxreplace=-1)
替换(年代,旧的,新的,maxreplace = 1)
replace (str, old, new[, maxreplace]) -> string
替换(str,旧的,新的[,maxreplace])- >字符串
Return a copy of string str with all occurrences of substring
返回字符串的副本与出现的所有子字符串str
old replaced by new. If the optional argument maxreplace is
老被新的取代。如果可选参数maxreplace
given, only the first maxreplace occurrences are replaced.
,只有第一个maxreplace事件所取代。
rfind(s, *args)
rfind(年代,* args)
rfind(s, sub [,start [,end]]) -> int
rfind(年代,子,开始[,]])- > int
Return the highest index in s where substring sub is found,
回报最高的指数在年代找到子字符串的子,
such that sub is contained within s[start,end]. Optional
这样的子是包含在s(开始、结束)。可选
arguments start and end are interpreted as in slice notation.
参数中解释为开始和结束符号。
Return -1 on failure.
失败返回1。
rindex(s, *args)
rindex(年代,* args)
rindex(s, sub [,start [,end]]) -> int
rindex(年代,子,开始[,]])- > int
Like rfind but raises ValueError when the substring is not found.
像rfind但ValueError当没有找到子字符串。
rjust(s, width, *args)
rjust(年代,宽度,* args)
rjust(s, width[, fillchar]) -> string
rjust(年代,宽度[fillchar])- >字符串
Return a right-justified version of s, in a field of the
返回一个右对齐的版本的年代,在一个领域
specified width, padded with spaces as needed. The string is
根据需要指定宽度,填补空间。字符串是
never truncated. If specified the fillchar is used instead of spaces.
从来没有截断。如果指定了fillchar代替空间。
rsplit(s, sep=None, maxsplit=-1)
rsplit(年代,9 = None,maxsplit = 1)
rsplit(s [,sep [,maxsplit]]) -> list of strings
rsplit(s[9月[,maxsplit]])- >字符串的列表
Return a list of the words in the string s, using sep as the
返回一个字符串中的词列表,使用9月作为
delimiter string, starting at the end of the string and working
分隔符字符串,字符串的结束和开始工作
to the front. If maxsplit is given, at most maxsplit splits are
到前面来。如果maxsplit最多maxsplit分裂
done. If sep is not specified or is None, any whitespace string
完成了。如果没有指定9月或没有任何空格的字符串
is a separator.
是一个分隔符。
rstrip(s, chars=None)
rstrip(年代,识字课=没有)
rstrip(s [,chars]) -> string
rstrip(s(字符))- >字符串
Return a copy of the string s with trailing whitespace removed.
返回一个字符串的副本年代尾随空格移除。
If chars is given and not None, remove characters in chars instead.
如果字符而不是没有,删除字符字符代替。
split(s, sep=None, maxsplit=-1)
分割(年代,9月= None,maxsplit = 1)
split(s [,sep [,maxsplit]]) -> list of strings
分割(s[9月[,maxsplit]])- >字符串的列表
Return a list of the words in the string s, using sep as the
返回一个字符串中的词列表,使用9月作为
delimiter string. If maxsplit is given, splits at no more than
分隔符的字符串。如果maxsplit,分裂不超过
maxsplit places (resulting in at most maxsplit+1 words). If sep
maxsplit地方(导致最多maxsplit + 1的话)。如果9月
is not specified or is None, any whitespace string is a separator.
没有指定或没有任何空格的字符串是一个分隔符。
(split and splitfields are synonymous)
(分裂和splitfields是同义的)
splitfields = split(s, sep=None, maxsplit=-1)
splitfields =分裂(年代,9 = None,maxsplit = 1)
split(s [,sep [,maxsplit]]) -> list of strings
分割(s[9月[,maxsplit]])- >字符串的列表
Return a list of the words in the string s, using sep as the
返回一个字符串中的词列表,使用9月作为
delimiter string. If maxsplit is given, splits at no more than
分隔符的字符串。如果maxsplit,分裂不超过
maxsplit places (resulting in at most maxsplit+1 words). If sep
maxsplit地方(导致最多maxsplit + 1的话)。如果9月
is not specified or is None, any whitespace string is a separator.
没有指定或没有任何空格的字符串是一个分隔符。
(split and splitfields are synonymous)
(分裂和splitfields是同义的)
strip(s, chars=None)
带(年代,识字课=没有)
strip(s [,chars]) -> string
带(s(字符))- >字符串
Return a copy of the string s with leading and trailing
返回字符串的副本与前导和尾随
whitespace removed.
空格移除。
If chars is given and not None, remove characters in chars instead.
如果字符而不是没有,删除字符字符代替。
If chars is unicode, S will be converted to unicode before stripping.
如果unicode字符,之前将被转换为unicode剥离。
swapcase(s)
swapcase(s)
swapcase(s) -> string
swapcase(s)- >字符串
Return a copy of the string s with upper case characters
返回字符串的副本与大写字符
converted to lowercase and vice versa.
转换为小写,反之亦然。
translate(s, table, deletions='')
翻译(年代,表,删除= ")
translate(s,table [,deletions]) -> string
翻译(年代,表[删除])- >字符串
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. The
转换表,它必须是一个字符串的长度为256。的
deletions argument is not allowed for Unicode strings.
删除对Unicode字符串参数是不允许的。
upper(s)
上(s)
upper(s) -> string
上(s)- >字符串
Return a copy of the string s converted to uppercase.
返回的字符串转换为大写。
zfill(x, width)
zfill(x,宽度)
zfill(x, width) -> string
zfill(x,宽度)- >字符串
Pad a numeric string x with zeros on the left, to fill a field
垫一个数字字符串x 0在左边,填补一个字段
of the specified width. The string x is never truncated.
指定的宽度。字符串x不会截断。
DATA
数据
ascii_letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters = ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_lowercase = ' abcdefghijklmnopqrstuvwxyz '
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ '
digits = '0123456789'
数字= ' 0123456789 '
hexdigits = '0123456789abcdefABCDEF'
hexdigits = ' 0123456789 abcdefabcdef '
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
信= ' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '
lowercase = 'abcdefghijklmnopqrstuvwxyz'
小写= ' abcdefghijklmnopqrstuvwxyz '
octdigits = '01234567'
octdigits = ' 01234567 '
printable = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTU...
可打印= ' 0123456789 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstu……