python的str类方法
来源:互联网 发布:怎么在淘宝里搜索店铺 编辑:程序博客网 时间:2024/06/05 14:33
class str(basestring) | str(object='') -> string | | 返回一个对象的字符串表示。 | 如果参数是一个字符串,返回值是相同的对象。 | | 方法解析顺序: | str | basestring | object | | 方法定义: | | __add__(...) | x.__add__(y) <==> x+y | | __contains__(...) | x.__contains__(y) <==> y in x | | __eq__(...) | x.__eq__(y) <==> x==y | | __format__(...) | S.__format__(format_spec) -> string | | 返回一个格式化的版本年代由format_spec描述。 | | __ge__(...) | x.__ge__(y) <==> x>=y | | __getattribute__(...) | x.__getattribute__('name') <==> x.name | | __getitem__(...) | x.__getitem__(y) <==> x[y] | | __getnewargs__(...) | | __getslice__(...) | x.__getslice__(i, j) <==> x[i:j] | | 不支持使用消极的指标。 | | __gt__(...) | x.__gt__(y) <==> x>y | | __hash__(...) | x.__hash__() <==> hash(x) | | __le__(...) | x.__le__(y) <==> x<=y | | __len__(...) | x.__len__() <==> len(x) | | __lt__(...) | x.__lt__(y) <==> x<y | | __mod__(...) | x.__mod__(y) <==> x%y | | __mul__(...) | x.__mul__(n) <==> x*n | | __ne__(...) | x.__ne__(y) <==> x!=y | | __repr__(...) | x.__repr__() <==> repr(x) | | __rmod__(...) | x.__rmod__(y) <==> y%x | | __rmul__(...) | x.__rmul__(n) <==> n*x | | __sizeof__(...) | S.__sizeof__() -> size of S in memory, in bytes | | __str__(...) | x.__str__() <==> str(x) | | capitalize(...) | S.capitalize() -> string | | 返回字符串第一个字符大写后的值。 | | center(...) | S.center(width[, fillchar]) -> string | | 返回一个给定width的字符串,并且原字符串集中在该字符串的中间,其它部分使用指定的字符字符填充(默认是一个空格) | | count(...) | S.count(sub[, start[, end]]) -> int | | 返回子串sub在S中出现的次数。可选参数start、end解释为切片符号。 | | decode(...) | S.decode([encoding[,errors]]) -> object | | 使用给定的编码encoding解码S。解码错误时,错误errors可以设定不同的错误处理方案,默认是 |“UnicodeDecodeError”,其他可能的值是“ignore”和“replace”以及任何其他编解码器注册过的名字。 |register_error是能够处理的“UnicodeDecodeErrors”。 | | encode(...) | S.encode([encoding[,errors]]) -> object | | 使用给定的编码encoding编码。编码出错时,错误errors可以设定不同的错误处理方案,默认是“strict” |意味着错误上升到“UnicodeEncodeError”,其他可能的值是“ignore”,“replace”和“xmlcharrefreplace” |以及其他编解码器注册过的名字。register_error是能够处理的“UnicodeDecodeErrors”。 | | endswith(...) | S.endswith(suffix[, start[, end]]) -> bool | | 如果S以指定的suffix结束,返回True,否则假。 | 用可选的参数start,在那个位置开始测试S。 | 用可选的参数end,在那个位置停止比较。 | suffix也可以尝试一个字符串的元组。 | | expandtabs(...) | S.expandtabs([tabsize]) -> string | | 返回一个所有制表符以指定数目tabsize空格显示的字符串。 | 如果tabsize没有给,一个tab大小8个字符。即‘\t’符号 | | find(...) | S.find(sub [,start [,end]]) -> int | | 返回子串在S中被发现的最小索引 | 这样的子串是包含在S[start:end],可选参数start和end解释为切片符号. | | 失败返回-1 | | format(...) | S.format(*args, **kwargs) -> string | | 返回一个格式化后的S,利用参数args和kwargs替换 | 替换的参数是通过花括号('{' and '}')。 | | index(...) | S.index(sub [,start [,end]]) -> int | | 但没有找到子字符串时上升到ValueError异常 | | isalnum(...) | S.isalnum() -> bool | | 如果在S中所有字符都是字母数字返回True | S中至少有一个字符,否则假。 | | isalpha(...) | S.isalpha() -> bool | | 如果在S中所有的字符都是字母返回True | S中至少有一个字符,否则假。 | | isdigit(...) | S.isdigit() -> bool | | 如果在S中所有的字符都是数字,返回True | S中至少有一个字符,否则假。 | | islower(...) | S.islower() -> bool | | 如果S中所有的字符都是小写的,返回True,S中至少有一个字符,否则假。 | | isspace(...) | S.isspace() -> bool | | 如果在S中所有的字符都是空格,返回True, | S中至少有一个字符,否则假。 | | istitle(...) | S.istitle() -> bool | | 如果在S中首字母大写,返回True,S中至少有一个字符,否则,返回False | | isupper(...) | S.isupper() -> bool | | 如果在S中所有的字符都是大写的,返回True,S中至少有一个字符,否则假。 | | join(...) | S.join(iterable) -> string | | 返回iterable的连接字符串,元素之间的分隔符是S。 |例如iterable=['a','b','c'] S='def' 结果是'adefbdefc' | | ljust(...) | S.ljust(width[, fillchar]) -> string | | 返回一个指定长度width的字符串,原字符S左对齐 |使用指定的填充字符填充(默认值是一个空格)。 | | lower(...) | S.lower() -> string | | 返回一个所有字符转换为小写的字符串。 | | lstrip(...) | S.lstrip([chars]) -> string or unicode | | 删除字符串左边的空格,然后返回。 | 如果chars存在而不是为None,删除S前面的指定字符chars,chars必须在最前面。 | 如果chars是unicode字符,S将在剥离前被转换为unicode | | partition(...) | S.partition(sep) -> (head, sep, tail) | | 用给定字符串sep分割S,将其分成三部分,sep前面的、sep和sep后面的,作为一个元组返回 | 如果分隔符sep没有在S中发现,返回S和两个空字符串 | | replace(...) | S.replace(old, new[, count]) -> string | | 将S中字符串old用new取代后返回 |如果可选参数count被提供,只有前count个old被取代 | | rfind(...) | S.rfind(sub [,start [,end]]) -> int | | 返回子串sub在S中被发现的最大的索引 | 这样的子串是包含在S[start:end]中 | 可选参数start和end被理解为切片符 | | 如果子串在S中没发现,返回-1 | | rindex(...) | S.rindex(sub [,start [,end]]) -> int | | 像S.rfind(),但没有找到子字符串时会报异常ValueError | | rjust(...) | S.rjust(width[, fillchar]) -> string | | 返回一个指定长度width的字符串,原字符S右对齐 |使用指定的填充字符填充(默认值是一个空格)。 | | rpartition(...) | S.rpartition(sep) -> (head, sep, tail) | | 用给定字符串sep分割S,将其分成三部分,sep前面的、sep和sep后面的,作为一个元组返回 | 但是如果分隔符sep没有在S中发现,返回两个空字符串和S,这点与partition函数相反,其它相同 | | rsplit(...) | S.rsplit([sep [,maxsplit]]) -> list of strings | | 使用sep作为分隔符分割字符串,返回剩下的字符串合成的列表(不包含sep)。 |如果maxsplit存在那么maxsplit是分割次数。 |如果sep没有指定或为None,那么空格是一个分隔符。 | | rstrip(...) | S.rstrip([chars]) -> string or unicode | | 删除字符串右边的空格,然后返回。 | 如果chars存在而且不是为None,删除S后面的指定字符chars,chars必须在最后面。 | 如果chars是unicode字符,S将在剥离前被转换为unicode | | split(...) | S.split([sep [,maxsplit]]) -> list of strings | | 使用sep作为分隔符分割字符串,返回剩下的字符串合成的列表(不包含sep)。 |如果maxsplit存在那么maxsplit是分割次数。 |如果sep没有指定或为None,那么空格是一个分隔符 | | splitlines(...) | S.splitlines(keepends=False) -> list of strings | | 将字符串的每一行作为列表的一个元素,返回该列表。 |换行符不包含在列表元素中,除非keepends为True。 | | startswith(...) | S.startswith(prefix[, start[, end]]) -> bool | | 如果S以指定的前缀prefix开始,返回True,否则返回False。 | 可选的参数start,表示在那个位置开始比较S | 可选的参数end,表示在那个位置停止比较S | prefix也可以是一个元组 | | strip(...) | S.strip([chars]) -> string or unicode | | 删除字符串左边和右边的空格,然后返回。 | 如果chars存在而且不是为None,删除S后面的指定字符chars,chars必须在最后面。 | 如果chars是unicode字符,S将在剥离前被转换为unicode | | swapcase(...) | S.swapcase() -> string | | 将S中的大写字符转换为小写,反之亦然 | | title(...) | S.title() -> string | | 返回一个首字母大写的字符串,即把S以大写字母开始,所有剩余的字符小写。 | | translate(...) | S.translate(table [,deletechars]) -> string | |通过表table转换字符串S的字符, 要过滤掉的字符放到del参数中,如果S中有del中的字符将被移除。 |from string import maketrans |tab=maketrans('aeiou','12345') |print 'this is a string example...wow!!!'.translate(tab) |结果: th3s 3s 1 str3ng 2x1mpl2...w4w!!! | | upper(...) | S.upper() -> string | | 将S中的字符转换为大写,然后返回 | | zfill(...) | S.zfill(width) -> string | | 返回指定长度width的字符串,在S的左边填充0,字符串S不会截断。 | | ---------------------------------------------------------------------- | Data and other attributes defined here: | | __new__ = <built-in method __new__ of type object> | T.__new__(S, ...) -> a new object with type S, a subtype of T
0 0
- python的str类方法
- Python中Str类的常用方法
- python str的一些方法
- Python的str类
- Python 实现str类型修改的方法
- python str.format()方法的基本用法
- python中字符串str的strip()方法
- python中字符串str的strip()方法
- Python中str的format()方法
- python-str方法使用
- python str 方法
- Python str.split方法
- Python str对象方法
- python-str(常用方法)
- Python str内置方法
- python的str,unicode对象的encode和decode方法
- python的str,unicode对象的encode和decode方法
- python的str,unicode对象的encode和decode方法
- 安装openVC 错误 from . import cv2 ImportError: DLL load failed
- maven介绍
- Integer源码详解
- C#开源系统大汇总
- siblings ---选择兄弟集合(标签相同)
- python的str类方法
- redux在react-native上使用(二)--加入redux-saga
- unity3d处理子弹发射后坐标系混乱问题
- iOS CoreLocation定位 使用方法
- BootStrap-链接调用
- C++ Vitual函数
- JavaScript学习three
- 阿里算法工程师电话面试总结
- redux在react-native上使用(三)--加入redux-thunk