python字符类方法

 
 def capitalize(self): # real signature unknown; restored from __doc__
        """ 使第一个字符大写,其余小写字母。
        S.capitalize() -> str
        
        Return a capitalized version of S, i.e. make the first character
        have upper case and the rest lower case.
        """
def center(self, width, fillchar=None): # real signature unknown; restored from __doc__
        """其效果和 lower() 方法非常相似,都可以转换字符串中所有大写字符为小写。
两者的区别是:lower() 方法只对ASCII编码,也就是‘A-Z’有效,
对于其他语言(非汉语或英文)中把大写转换为小写的情况只能用 casefold() 方法 
        Return S centered in a string of length width. Padding is
        done using the specified fill character (default is a space)
        """
        return ""

 def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
        """方法用于统计字符串中某个子字符串出现的次数,可选参数为开始搜索与结束搜索的位置索引。方法用于统计字符串中某个子字符串出现的次数,可选参数为开始搜索与结束搜索的位置索引。
        S.count(sub[, start[, end]]) -> int
        
        Return the number of non-overlapping occurrences of substring sub in
        string S[start:end].  Optional arguments start and end are
        interpreted as in slice notation.
        """
        return 0

 def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
        """方法以指定的编码格式编码字符串,默认编码为 'utf-8'。
        S.encode(encoding='utf-8', errors='strict') -> bytes
        
        Encode S using the codec registered for encoding. Default encoding
        is 'utf-8'. errors may be given to set a different error
        handling scheme. Default is 'strict' meaning that encoding errors raise
        a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
        'xmlcharrefreplace' as well as any other name registered with
        codecs.register_error that can handle UnicodeEncodeErrors.
        """
        return b""

def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__
        """方法用于判断字符串是否以指定后缀结尾,如果是则返回 True,否则返回 False。
        S.endswith(suffix[, start[, end]]) -> bool
        
        Return True if S ends with the specified suffix, False otherwise.
        With optional start, test S beginning at that position.
        With optional end, stop comparing S at that position.
        suffix can also be a tuple of strings to try.
        """
        return False

 def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__
        """把字符串中的 tab 符号('\t')转为空格,tab 符号('\t')默认的空格数是 8。
            从头开始数,数到第一个\t正好为8个空格,不足则补空格,如果还有\t,
            接着从第一个\t数到第二个\t仍然为8个空格,以此类推直到最后一个\t结束。
        S.expandtabs(tabsize=8) -> str
        
        Return a copy of S where all tab characters are expanded using spaces.
        If tabsize is not given, a tab size of 8 characters is assumed.
        """
        return ""

 def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
        """从字符串中找出某个子字符串第一个匹配项的索引位置,该方法与 index() 方法一样,只不过如果子字符串不在字符串中不会报异常,而是返回-1。
        S.find(sub[, start[, end]]) -> int
        
        Return the lowest 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.
        """
        return 0

def format(self, *args, **kwargs): # known special case of str.format
        """格式换字符串输出(方法与%相似,但可以指定顺序)
        S.format(*args, **kwargs) -> str
        
        Return a formatted version of S, using substitutions from args and kwargs.
        The substitutions are identified by braces ('{' and '}').
        """
        pass

def format_map(self, mapping): # real signature unknown; restored from __doc__
        """执行字符串格式化操作,替换字段使用{}分隔,同str.format(**mapping), 除了直接使用mapping,而不复制到一个dict
        S.format_map(mapping) -> str
        
        Return a formatted version of S, using substitutions from mapping.
        The substitutions are identified by braces ('{' and '}').
        """
        return ""
def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
        """检测字符串string中是否包含子字符串 sub,如果存在,则返回sub在string中的索引值(下标),
            如果指定began(开始)和 end(结束)范围,则检查是否包含在指定范围内,
            该方法与 python find()方法一样,只不过如果str不在 string中会报一个异常
        S.index(sub[, start[, end]]) -> int
        
        Return the lowest 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.
        
        Raises ValueError when the substring is not found.
        """
        return 0
def isalnum(self): # real signature unknown; restored from __doc__
        """判断字符串String是否由字符串或数字组成,并且至少有一个字符(不为空)
        S.isalnum() -> bool
        
        Return True if all characters in S are alphanumeric
        and there is at least one character in S, False otherwise.
        """
        return False
def isalpha(self): # real signature unknown; restored from __doc__
        """判断字符串String是否只由字母组成,并且至少有一个字符(不为空)
        S.isalpha() -> bool
        
        Return True if all characters in S are alphabetic
        and there is at least one character in S, False otherwise.
        """
        return False

 def isdecimal(self): # real signature unknown; restored from __doc__
        """判断字符串String是否只由小数/数字/数值组成,并且至少有一个字符(不为空)
        S.isdecimal() -> bool
        
        Return True if there are only decimal characters in S,
        False otherwise.
        """
        return False
 def isdigit(self): # real signature unknown; restored from __doc__
        """
        S.isdigit() -> bool
        
        Return True if all characters in S are digits
        and there is at least one character in S, False otherwise.
        """
        return False

def isidentifier(self): # real signature unknown; restored from __doc__
        """判断字符串中是否是有效标识符
        S.isidentifier() -> bool
        
        Return True if S is a valid identifier according
        to the language definition.
        
        Use keyword.iskeyword() to test for reserved identifiers
        such as "def" and "class".
        """

def islower(self): # real signature unknown; restored from __doc__
        """判断字符串中是否是有效标识符
        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.
        """
        return False

def isnumeric(self): # real signature unknown; restored from __doc__
        """
        S.isnumeric() -> bool
        
        Return True if there are only numeric characters in S,
        False otherwise.
        """
        return False
 def isprintable(self): # real signature unknown; restored from __doc__
        """
        S.isprintable() -> bool
        
        Return True if all characters in S are considered
        printable in repr() or S is empty, False otherwise.
        """
        return False
def isspace(self): # real signature unknown; restored from __doc__
        """检测字符串是否只由空格组成,并且至少有一个字符(判断字符串中是否至少有一个字符,并且所有字符都是空白字符。)
        S.isspace() -> bool
        
        Return True if all characters in S are whitespace
        and there is at least one character in S, False otherwise.
        """
        return False
 def istitle(self): # real signature unknown; restored from __doc__
        """ 判断字符串中的字符是否是首字母大写,且其他字母为小写,其会忽视非字母字符
        S.istitle() -> bool
        
        Return True if S is a titlecased string and there is at least one
        character in S, i.e. upper- and titlecase characters may only
        follow uncased characters and lowercase characters only cased ones.
        Return False otherwise.
        """
        return False
 def isupper(self): # real signature unknown; restored from __doc__
        """检测字符串中所有的字母是否都为大写
        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.
        """
        return False
 def join(self, iterable): # real signature unknown; restored from __doc__
        """用于将可迭代对象中的元素以指定的字符连接生成一个新的字符串。
        S.join(iterable) -> str
        
        Return a string which is the concatenation of the strings in the
        iterable.  The separator between elements is S.
        """
        return ""
def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__
        """返回一个原字符串左对齐,并使用指定字符填充至指定长度的新字符串,默认的填充字符为空格。如果指定的长度小于原字符串的长度则返回原字符串。
        S.ljust(width[, fillchar]) -> str
        
        Return S left-justified in a Unicode string of length width. Padding is
        done using the specified fill character (default is a space).
        """
        return ""
 def lower(self): # real signature unknown; restored from __doc__
        """转换字符串中所有大写字符为小写,其效果和 casefold() 方法非常相似。
            两者的区别是:lower() 方法只对ASCII编码,也就是‘A-Z’有效,对于其他语言(非汉语或英文)
            中把大写转换为小写的情况只能用 casefold() 方法。
        S.lower() -> str
        
        Return a copy of the string S converted to lowercase.
        """
        return ""

    def lstrip(self, chars=None): # real signature unknown; restored from __doc__
        """用于删除字符串头部指定的字符,默认字符为所有空字符,包括空格、换行(\n)、制表符(\t)等。
        S.lstrip([chars]) -> str
        
        Return a copy of the string S with leading whitespace removed.
        If chars is given and not None, remove characters in chars instead.
        """
        return ""

    def maketrans(self, *args, **kwargs): # real signature unknown
        """Python maketrans() 方法用于给 translate() 方法创建字符映射转换表。


可以只接受一个参数,此时这个参数是个字典类型(暂不研究这种情况)。


对于接受两个参数的最简单的调用方式,第一个参数是字符串,表示需要转换的字符,第二个参数也是字符串,
表示转换的目标。两个字符串的长度必须相同,为一一对应的关系。


在Python3中可以有第三个参数,表示要删除的字符,也是字符串。


一般 maketrans() 方法需要配合 translate() 方法一起使用。


注:Python3.4 以后已经不需要从外部 string 模块中来调用 maketrans() 方法了,取而代之的是内建函数: 
bytearray.maketrans()、bytes.maketrans()、str.maketrans()。
        Return a translation table usable for str.translate().
        
        If there is only one argument, it must be a dictionary mapping Unicode
        ordinals (integers) or characters to Unicode ordinals, strings or None.
        Character keys will be then converted to ordinals.
        If there are two arguments, they must be strings of equal length, and
        in the resulting dictionary, each character in x will be mapped to the
        character at the same position in y. If there is a third argument, it
        must be a string, whose characters will be mapped to None in the result.
        """
        pass
    def partition(self, sep): # real signature unknown; restored from __doc__
        """用来根据指定的分隔符将字符串进行分割。
如果字符串包含指定的分隔符,则返回一个3元的元组,第一个为分隔符前面的子字符串,
第二个为分隔符本身,第三个为分隔符后面的子字符串。
partition() 方法是在Python 2.5中新增的。
        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.
        """
        pass
    def replace(self, old, new, count=None): # real signature unknown; restored from __doc__
        """用于把字符串中指定的旧子字符串替换成指定的新子字符串,如果指定 count 可选参数则替换指定的次数,默认全部替换。
        S.replace(old, new[, count]) -> str
        
        Return a copy of S with all occurrences of substring
        old replaced by new.  If the optional argument count is
        given, only the first count occurrences are replaced.
        """
        return "
    def rindex(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
        """
        S.rindex(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.
        
        Raises ValueError when the substring is not found.
        """
        return 0

    def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__
        """
        S.rjust(width[, fillchar]) -> str
        
        Return S right-justified in a string of length width. Padding is
        done using the specified fill character (default is a space).
        """
        return ""

    def rpartition(self, sep): # real signature unknown; restored from __doc__
        """
        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.
        """
        pass

    def rsplit(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
        """
        S.rsplit(sep=None, maxsplit=-1) -> list of strings
        
        Return a list of the words in 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, any whitespace string
        is a separator.
        """
        return []

    def rstrip(self, chars=None): # real signature unknown; restored from __doc__
        """
        S.rstrip([chars]) -> str
        
        Return a copy of the string S with trailing whitespace removed.
        If chars is given and not None, remove characters in chars instead.
        """
        return ""

    def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
        """通过指定分隔符对字符串进行分割并返回一个列表,默认分隔符为所有空字符,包括空格、换行(\n)、制表符(\t)等。
        S.split(sep=None, maxsplit=-1) -> list of strings
        
        Return a list of the words in 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.
        """
        return []

    def splitlines(self, keepends=None): # real signature unknown; restored from __doc__
        """splitlines() 按照行界符('\r', '\r\n', \n'等)分隔,返回一个包含各行作为元素的列表,默认不包含行界符。
        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.
        """
        return []

    def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__
        """用于判断字符串是否以指定前缀开头,如果是则返回 True,否则返回 False。
        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.
        """
        return False

    def strip(self, chars=None): # real signature unknown; restored from __doc__
        """用于删除字符串头部和尾部指定的字符,默认字符为所有空字符,包括空格、换行(\n)、制表符(\t)等。
        S.strip([chars]) -> str
        
        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.
        """
        return ""

    def swapcase(self): # real signature unknown; restored from __doc__
        """ swapcase() 方法用于对字符串的大小写字母进行转换
        S.swapcase() -> str
        
        Return a copy of S with uppercase characters converted to lowercase
        and vice versa.
        """
        return ""

    def title(self): # real signature unknown; restored from __doc__
        """
        S.title() -> str
        
        Return a titlecased version of S, i.e. words start with title case
        characters, all remaining cased characters have lower case.
        """
        return ""

    def translate(self, table): # real signature unknown; restored from __doc__
        """ translate() 方法根据 maketrans() 方法给出的字符映射转换表转换字符串中的字符。
        S.translate(table) -> str
        
        Return a copy of the string S in which each character has been mapped
        through the given translation table. The table must implement
        lookup/indexing via __getitem__, for instance a dictionary or list,
        mapping Unicode ordinals to Unicode ordinals, strings, or None. If
        this operation raises LookupError, the character is left untouched.
        Characters mapped to None are deleted.
        """
        return ""

    def upper(self): # real signature unknown; restored from __doc__
        """
        S.upper() -> str
        
        Return a copy of S converted to uppercase.
        """
        return ""

    def zfill(self, width): # real signature unknown; restored from __doc__
        """zfill() 方法返回指定长度的字符串,原字符串右对齐,前面填充0。
        S.zfill(width) -> str
        
        Pad a numeric string S with zeros on the left, to fill a field
        of the specified width. The string S is never truncated.
        """
        return ""













  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值