标签:index als default 默认 errors self arch set object
islower(...)
#判断字符串中的字母是否全部是小写
| S.islower() -> bool
|
| Return True if all cased characters in S are lowercase and there is
| at least one cased character in S, False otherwise.
|
| isspace(...)
#判断字符串里是否全部是空格,全空格返回True
| S.isspace() -> bool
|
| Return True if all characters in S are whitespace
| and there is at least one character in S, False otherwise.
|
| istitle(...)
#判断字符串中首字母是否是大写并且其余字母小写
| S.istitle() -> bool
|
| Return True if S is a titlecased string and there is at least one
| character in S, i.e. uppercase characters may only follow uncased
| characters and lowercase characters only cased ones. Return False
| otherwise.
isupper(...)
#判断是否全部是大写
| S.isupper() -> bool
|
| Return True if all cased characters in S are uppercase and there is
| at least one cased character in S, False otherwise.
|
| join(...)
#将多个字符或字符串组合成一个字符串。如 ‘ ’.join(s)
| S.join(iterable) -> string
|
| Return a string which is the concatenation of the strings in the
| iterable. The separator between elements is S.
|
| ljust(...)
#左对齐,右填充字符。同center
| S.ljust(width[, fillchar]) -> string
|
| Return S left-justified in a string of length width. Padding is
| done using the specified fill character (default is a space).
|
| lower(...)
#全部转小写
| S.lower() -> string
|
| Return a copy of the string S converted to lowercase.
lstrip(...)
#strip()为去掉字符串前后的空格,lstrip与rstrip为去掉左端或者右端的空格
| S.lstrip([chars]) -> string or unicode
|
| Return a copy of the string S with leading 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
partition(...)
#它用来根据指定的分隔符将字符串进行分割,如果字符串包含指定的分隔符,则返回一个3元的tuple,第一个为分隔符左边的子串,第二个为分隔符本身,第三个为分隔符右边的子串。第二个例子说明,如果找不到指定的分隔符,则返回仍然是一个3元的tuple,第一个为整个字符串,第二和第三个为空串。
它与split(sep, 1)有什么区别呢?首先split返回的可能不是固定长度的返回值,它返回的是一个list,如果找到,则返回一个2元list,如果没找到,则返回一个1元的list,如:
>>> ‘a.b.c’.split(‘,’, 1)
[‘a.b.c‘]
>>> ‘a.b.c’.split(‘.’, 1)
[‘a‘, ‘b.c‘]
| S.partition(sep) -> (head, sep, tail)
|
| Search for the separator sep in S, and return the part before it,
| the separator itself, and the part after it. If the separator is not
| found, return S and two empty strings.
|
| replace(...)
#字符串替换。例如:s.replace(‘a‘,‘b‘)将字符串中的‘a‘全部替换成‘b’
| S.replace(old, new[, count]) -> string
|
| Return a copy of string S with all occurrences of substring
| old replaced by new. If the optional argument count is
| given, only the first count occurrences are replaced.
|
| rfind(...)
#从右开始查找,未找到返回-1
| S.rfind(sub [,start [,end]]) -> int
|
| Return the highest index in S where substring sub is found,
| such that sub is contained within s[start:end]. Optional
| arguments start and end are interpreted as in slice notation.
|
| Return -1 on failure.
rindex(...)
#从右开始。。。同index
| S.rindex(sub [,start [,end]]) -> int
|
| Like S.rfind() but raise ValueError when the substring is not found.
|
| rjust(...)
#从右开始
| S.rjust(width[, fillchar]) -> string
|
| Return S right-justified in a string of length width. Padding is
| done using the specified fill character (default is a space)
|
| rpartition(...)
#从右开始
| S.rpartition(sep) -> (head, sep, tail)
|
| Search for the separator sep in S, starting at the end of S, and return
| the part before it, the separator itself, and the part after it. If the
| separator is not found, return two empty strings and S.
rsplit(...)
#从右开始分割,默认以空格,或者可以在括号内写分割要求。例如split(‘o‘,2) 代表用O作为分割位,切2次。
| S.rsplit([sep [,maxsplit]]) -> list of strings
|
| 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. If maxsplit is given, at most maxsplit splits are
| done. If sep is not specified or is None, any whitespace string
| is a separator.
rstrip(...)
#移除字符串头尾指定的字符(默认为空格)
| S.rstrip([chars]) -> string or unicode
|
| Return a copy of the string S with 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
|
| split(...)
#将字符串分割成列表,默认以空格分割
| S.split([sep [,maxsplit]]) -> list of strings
|
| Return a list of the words in the string S, using sep as the
| delimiter string. If maxsplit is given, at most maxsplit
| splits are done. If sep is not specified or is None, any
| whitespace string is a separator and empty strings are removed
| from the result.
splitlines(...)
| S.splitlines([keepends]) -> list of strings
|
| Return a list of the lines in S, breaking at line boundaries.
| Line breaks are not included in the resulting list unless keepends
| is given and true.
|
| startswith(...)
| S.startswith(prefix[, start[, end]]) -> bool
|
| Return True if S starts with the specified prefix, False otherwise.
| With optional start, test S beginning at that position.
| With optional end, stop comparing S at that position.
| prefix can also be a tuple of strings to try.
|
| strip(...)
| S.strip([chars]) -> string or unicode
|
| 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
标签:index als default 默认 errors self arch set object
原文地址:http://www.cnblogs.com/yebin17937901/p/7300803.html