学习

python字符串函数

2018-04-23  本文已影响1人  TimeSHU

str.capitalize(self)        首字母变大写        返回值:    S.capitalize() -> string

str.count(self, sub, start=None, end=None        子序列个数        返回值:       S.count(sub[, start[, end]]) -> int

str.decode(self, encoding=None, errors=None)        解码        返回值:    S.decode([encoding[,errors]]) -> object

str.encode(self, encoding=None, errors=None)        编码,针对unicode        返回值:    S.encode([encoding[,errors]]) -> object

str.endswith(self, suffix, start=None, end=None)        是否以 xxx 结束        返回值:S.endswith(suffix[, start[, end]]) -> bool

str.expandtabs(self, tabsize=None)        将tab转换成空格,默认一个tab转换成8个空格        返回值:    S.expandtabs([tabsize]) -> string

str.find(self, sub, start=None, end=None)        寻找子序列位置,如果没找到,返回 -1        返回值:    S.find(sub [,start [,end]]) -> int

str.format(*args, **kwargs):        字符串格式化,动态参数        返回值:    S.format(*args, **kwargs) -> string

str.index(self, sub, start=None, end=None)        子序列位置,如果没找到,报错        返回值:    S.index(sub [,start [,end]]) -> int

str.isalnum(self)        是否是字母和数字        返回值:    S.isalnum() -> bool

str.isalpha(self)         是否是字母        返回值:    S.isalpha() -> bool

str.isdigit(self)        是否是数字        返回值:    S.isdigit() -> bool

str.islower(self)        是否小写        返回值:    S.islower() -> bool

str.isspace(self)                                  返回值:    S.isspace() -> bool

str.istitle(self)                                       返回值:    S.istitle() -> bool

str.isupper(self)                                 返回值:    S.isupper() -> bool

str. join(self, iterable)         连接        返回值:      S.join(iterable) -> string

str. ljust(self, width, fillchar=None):         内容左对齐,右侧填充        返回值:     S.ljust(width[, fillchar]) -> string

str. lower(self):        变小写         返回值:    S.lower() -> string

str. lstrip(self, chars=None)        移除左侧空白        返回值:    S.lstrip([chars]) -> stringor unicode

str.partition(self, sep)        分割,前,中,后三部分        返回值:    S.partition(sep) -> (head, sep, tail)

str.replace(self, old, new, count=None)        替换            返回值:    S.replace(old, new[, count]) -> string

str.rfind(self, sub, start=None, end=None)                返回值:         S.rfind(sub [,start [,end]]) -> int

str. rindex(self, sub, start=None, end=None)            返回值:         S.rindex(sub [,start [,end]]) -> int

str.rjust(self, width, fillchar=None)                返回值:        S.rjust(width[, fillchar]) -> string

str.rpartition(self, sep):                            返回值:        S.rpartition(sep) -> (head, sep, tail)

str.rsplit(self, sep=None, maxsplit=None)            返回值:        S.rsplit([sep [,maxsplit]]) -> list of strings

str.rstrip(self, chars=None)                返回值:        S.rstrip([chars]) -> stringor unicode

str.split(self, sep=None, maxsplit=None)        分割, maxsplit最多分割几次        返回值:       S.split([sep [,maxsplit]]) -> list of strings

str.splitlines(self, keepends=False)            根据换行分割            返回值:       S.splitlines(keepends=False) -> list of strings

str.startswith(self, prefix, start=None, end=None)        是否起始        返回值:       S.startswith(prefix[, start[, end]]) -> bool

str.strip(self, chars=None)        移除两段空白            返回值:       S.strip([chars]) -> stringor unicode

str.swapcase(self)        大写变小写,小写变大写        返回值:        S.swapcase() -> string

str.title(self)                                                                    返回值:        S.title() -> string

str.translate(self, table, deletechars=None)            转换,需要先做一个对应表,最后一个表示删除字符集合 

                                                                                        返回值:       S.translate(table [,deletechars]) -> string

str.center(self, width, fillchar=None)        内容居中,width:总长度;fillchar:空白处填充内容,默认无        

                                                                        返回值:    S.center(width[, fillchar]) -> string

str. upper(self)                                                            返回值:        S.upper() -> string

str.zfill(self, width)        方法返回指定长度的字符串,原字符串右对齐,前面填充0。        返回值:        S.zfill(width) -> string


def _formatter_field_name_split(self, *args, **kwargs): # real signature unknown

        pass

def _formatter_parser(self, *args, **kwargs): # real signature unknown

        pass

def __add__(self, y): 

        """x.__add__(y) <==> x+y"""        pass 

def __contains__(self, y): 

        """x.__contains__(y) <==> yinx"""        pass

def __eq__(self, y): 

        """x.__eq__(y) <==> x==y"""        pass

def __format__(self, format_spec): 

        """        S.__format__(format_spec) -> string

def __getattribute__(self, name): 

        """x.__getattribute__('name') <==> x.name"""        pass

def __getitem__(self, y): 

        """x.__getitem__(y) <==> x[y]"""        pass

def __getnewargs__(self, *args, **kwargs): # real signature unknown

        pass

    def __getslice__(self, i, j): 

        """        x.__getslice__(i, j) <==> x[i:j]

    def __ge__(self, y): 

        """x.__ge__(y) <==> x>=y"""        pass

    def __gt__(self, y): 

        """x.__gt__(y) <==> x>y"""        pass

    def __hash__(self): 

        """x.__hash__() <==> hash(x)"""        pass

    def __init__(self, string=''): # known special case of str.__init__

        """        str(object='') -> string

        Return a nice string representation of the object.

        If the argument isa string, thereturnvalueis the same object.

        # (copied from class doc)"""        pass

    def __len__(self): 

        """x.__len__() <==> len(x)"""        pass

    def __le__(self, y): 

        """x.__le__(y) <==> x<=y"""        pass

    def __lt__(self, y): 

        """x.__lt__(y) <==> x

    def __mod__(self, y): 

        """x.__mod__(y) <==> x%y"""        pass

    def __mul__(self, n): 

        """x.__mul__(n) <==> x*n"""        pass

    @staticmethod # known case of __new__

    def __new__(S, *more): 

        """T.__new__(S, ...) -> a new object with type S, a subtype of T"""        pass

    def __ne__(self, y): 

        """x.__ne__(y) <==> x!=y"""        pass

    def __repr__(self): 

        """x.__repr__() <==> repr(x)"""        pass

    def __rmod__(self, y): 

        """x.__rmod__(y) <==> y%x"""        pass

    def __rmul__(self, n): 

        """x.__rmul__(n) <==> n*x"""        pass

    def __sizeof__(self): 

        """S.__sizeof__() -> size of Sinmemory,inbytes"""        pass

    def __str__(self): 

        """x.__str__() <==> str(x)"""        pass

上一篇 下一篇

猜你喜欢

热点阅读