konglingchao

2018-06-07 

Type   方法名称 使用案例  备注信息
 
str.capitalize(self)
# 首字母大写
In [1]: str="konglingchao"

In [2]: v=str.capitalize()
In [3]: print(v)
Konglingchao
    def capitalize(self): # real signature unknown; restored from __doc__
        """
        B.capitalize() -> copy of B

        Return a copy of B with only its first character capitalized (ASCII)
        and the rest lower-cased.
        """
        pass
 
str.casefold(self)
#可对未知字符进行相应的大小写转换

str.swapcase(self)
#大小写互相转换
str.lower(self)
# 小写转换

In [19]: str="KongLingChao"
In [20]: v=str.casefold()
In [21]: print(v)
konglingchao
In [22]: v=str.lower()
In [23]: print(v)
konglingchao

    def casefold(self): # real signature unknown; restored from __doc__
        """
        S.casefold() -> str

        Return a version of S suitable for caseless comparisons.
        """
        return ""
    def swapcase(self): # real signature unknown; restored from __doc__
        """
        B.swapcase() -> copy of B

        Return a copy of B with uppercase ASCII characters converted
        to lowercase ASCII and vice versa.
        """
        pass
   
str.center(self, width, fillchar=None)
#width设置宽度,将内容居中
#fiddchar设置填充字符
ljust(self, width, fillchar=None)
#将字符放左边
rjust(self, width, fillchar=None)
#将字符放右边

 

In [1]: str="konglingchao"

In [2]: v=str.center(20,"-")

In [3]: print(v) ----konglingchao----

 

In [14]: print("konglingchao".ljust(20,"*"))

konglingchao********

 

In [15]: print("konglingchao".rjust(20,"*"))

********konglingchao

    def center(self, width, fillchar=None): # real signature unknown; restored from __doc__
        """
        S.center(width[, fillchar]) -> str

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

        Return B left justified in a string of length width. Padding is
        done using the specified fill character (default is a space).
        """
        pass

    def rjust(self, width, fillchar=None): # real signature unknown; restored from __doc__

        """

        B.rjust(width[, fillchar]) -> copy of B

 

        Return B right justified in a string of length width. Padding is

        done using the specified fill character (default is a space)

        """

        pass

 
str.count(self,sub,start=None,end=None)
# sub 在字符串中要sa查找子序列出现的次数

 

 
In [8]: str="konglingchao"

In [9]: v=str.count(\'ao\',3,12)

In [10]: print(v)
 
 
    def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
        """
        B.count(sub[, start[, end]]) -> int

        Return the number of non-overlapping occurrences of subsection sub in
        bytes B[start:end].  Optional arguments start and end are interpreted
        as in slice notation.
        """
        return 0
       
    def decode(self, *args, **kwargs): # real signature unknown
        """
        Decode the bytearray using the codec registered for encoding.

          encoding
            The encoding with which to decode the bytearray.
          errors
            The error handling scheme to use for the handling of decoding errors.
            The default is \'strict\' meaning that decoding errors raise a
            UnicodeDecodeError. Other possible values are \'ignore\' and \'replace\'
            as well as any other name registered with codecs.register_error that
            can handle UnicodeDecodeErrors.
        """
        pass
 
str.find(self, sub, start=None, end=None)
# 检测字符串中是否包含子字符串sub
# str.index() 找不到值会直接报错

 

 
In [13]: str="konglingchao"

In [14]: v=str.find("o")

In [15]: print(v)
1

In [16]: v=str.find("o",9,10)

In [17]: print(v)
-1
 
 
    def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
        """
        B.find(sub[, start[, end]]) -> int

        Return the lowest index in B where subsection sub is found,
        such that sub is contained within B[start,end].  Optional
        arguments start and end are interpreted as in slice notation.

        Return -1 on failure.
        """
        return 0
       
    def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__
        """
        B.expandtabs(tabsize=8) -> copy of B

        Return a copy of B where all tab characters are expanded using spaces.
        If tabsize is not given, a tab size of 8 characters is assumed.
        """
        pass
       
    def extend(self, *args, **kwargs): # real signature unknown
        """
        Append all the items from the iterator or sequence to the end of the bytearray.

          iterable_of_ints
            The iterable of items to append.
        """
        pass
   
str.isalnum(self)
# 判断字符串中是否只包含数字和字母
In [20]: str="konglingchao"
In [21]: v=str.isalnum()
In [22]: str="konglingchao_123"
In [23]: v=str.isalnum()
In [24]: print(v)
False
In [25]: str="konglingchao123"
In [26]: v=str.isalnum()
In [27]: print(v)
True
 
    def isalnum(self): # real signature unknown; restored from __doc__
        """
        B.isalnum() -> bool

        Return True if all characters in B are alphanumeric
        and there is at least one character in B, False otherwise.
        """
        return Falseal
 
str.isdecimal(self)
# 十进制,使用比较多

str.isdigit(self) # 判断字符串是否为数字,isdigit 判断特殊数字 str.isnumeric(self) # 可判断中文数字

 

 
In [1]: list=[\'1\',"",""]

 

In [2]: v1=list[0].isdecimal()

 

In [3]: v2=list[1].isdigit()

 

In [4]: v3=list[2].isnumeric()

 

In [5]: print(v1,v2,v3)

True True True

In [12]: v4=list[1].isdecimal()

 

In [13]: v5=list[2].isdigit()

 

In [14]: print(v4,v5)

False False

 

 

 

    def isdigit(self): # real signature unknown; restored from __doc__

        """

        B.isdigit() -> bool

 

        Return True if all characters in B are digits

        and there is at least one character in B, False otherwise.

        """

        return False

 

    def isdecimal(self): # real signature unknown; restored from __doc__

        """

        S.isdecimal() -> bool

 

        Return True if there are only decimal characters 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

 

 
str.isidentifier(self)
#判断字符串是否可为合法的标识符

 

 
In [9]: str="123"

In [10]: v=str.isidentifier()

In [11]: print(v)
False

In [12]: str="_123"

In [13]: v=str.isidentifier()

In [14]: print(v)
True

 

 

    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".

        """

        return False

 
str.isalpha(self)
#判断字符串中是否只有包含字母

 

 
In [1]: str="konglingchao"

In [2]: v=str.isalpha()

In [3]: print(v)
True

 

 

    def isalpha(self): # real signature unknown; restored from __doc__
        """
        B.isalpha() -> bool

        Return True if all characters in B are alphabetic
        and there is at least one character in B, False otherwise.
        """
        return False

 
str. format(*args, **kwargs)
#格式化,将字符串中的占位符替换为指定的值
 
In [3]: str=\'I am {name},age {a}\'
In [4]: v=str.format(name=\'kong\',a=30)
#or v=str.format_map({\'name\':\'kong\',\'a\':12})
In [
5]: print(v) I am kong,age 30 In [6]: str=\'I am {0},age {1}\' In [7]: v=str.format(\'kong\',30) In [8]: print(v) I am kong,age 30
def format(*args, **kwargs): # real signature unknown
    """
    Return value.__format__(format_spec)

    format_spec defaults to the empty string
    """
    pass
 
 
str.expandtabs(self, tabsize=8)
#以"\t" 空格 为分割符,补齐已tab分割的字符位=tabsize
 
In [2]: str="Name\taddr\tage\nkong\tBeiJing\t19"

In [3]: v=str.expandtabs(20)

In [4]: print(v)
Name                addr                age
kong                BeiJing             19
    def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__
        """
        B.expandtabs(tabsize=8) -> copy of B

        Return a copy of B where all tab characters are expanded using spaces.
        If tabsize is not given, a tab size of 8 characters is assumed.
        """
        pass
 
 
str.swapcase(self)
#大小写转换

 

 
In [4]: str="KONGlINGchao"

In [5]: v=str.swapcase()

In [6]: print(v)
kongLingCHAO
 
 
    def swapcase(self): # real signature unknown; restored from __doc__
        """
        B.swapcase() -> copy of B

        Return a copy of B with uppercase ASCII characters converted
        to lowercase ASCII and vice versa.
        """
        pass

 

   
str.isprintable(self)
# 是否存在不可显示的字符  ,如\n \t

 

In [18]: "kong\tlingchao".isprintable()
Out[18]: 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

 

 
str.isspace(self)
# 判断是否全部为空格
In [1]: str="kong ling chao"

In [2]: str.isspace()
Out[2]: False

In [3]: " ".isspace()
Out[3]: True

In [4]: "".isspace()

Out[4]: 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
 
str=title(self)
# 将字符串转换为标题
str=istitle(self)
# 判断字符串是否为标题
 
In [5]: str="Return a titlecased version of"

In [6]: str.title()
Out[6]: \'Return A Titlecased Version Of\'

In [7]: v=str.title()

In [8]: print(v.istitle())
True

In [9]: print(str.istitle())
False

 

 

    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 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
   
join(self,*args,**kwargs)
#  字符串拼接, 已join之前的字符拼接()里的字符。

 

In [10]: str="konglingchao"

In [11]: print("*".join(str))
k*o*n*g*l*i*n*g*c*h*a*o
 
 
    def join(self, *args, **kwargs): # real signature unknown
        """
        Concatenate any number of bytes/bytearray objects.

        The bytearray whose method is called is inserted in between each pair.

        The result is returned as a new bytearray object.
        """
        pass
   
str.islower(self)
# 判断是否为小写
str.lower(self)
# 转换为小写

 

 
In [16]: str="konglIngchao"

In [17]: print(str.islower())
False

In [18]: print(str.lower())
konglingchao

 

 

    def islower(self): # real signature unknown; restored from __doc__

        """

        B.islower() -> bool

 

        Return True if all cased characters in B are lowercase and there is

        at least one cased character in B, False otherwise.

        """

        return False

  def lower(self): # real signature unknown; restored from __doc__
      """
      B.lower() -> copy of B

      Return a copy of B with all ASCII characters converted to lowercase.
      """
      pass
   
str.isupper()
# 判断是否为大写
str.upper()
# 转换为大写

 

 
In [19]: str="konglIngchao"

In [20]: print(str.isupper())
False

In [21]: print(str.upper())
KONGLINGCHAO




 
    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 upper(self): # real signature unknown; restored from __doc__
        """
        B.upper() -> copy of B

        Return a copy of B with all ASCII characters converted to uppercase.
        """
        pass
   
str.rstrip(self)
# 默认处理右边空格
str.lstrip(self)
# 默认处理左边空格
str.strip(self)
# 默认处理两边空格
# 可匹配清除指定 \n \t 字符

 

 
In [1]: str="    KONGLINGCHAO    "

In [2]: print(str.rstrip(),str.lstrip(),str.strip())
    KONGLINGCHAO KONGLINGCHAO     KONGLINGCHAO

In [3]: str="\nKONGLINGCHAO\t"

In [4]: print(str.rstrip(),str.lstrip(),str.strip())

KONGLINGCHAO KONGLINGCHAO     KONGLINGCHAO

In [5]: str="nullKONGLINGCHAO"

In [6]: print(str.lstrip(\'null\'))
KONGLINGCHAO

 

    def lstrip(self, chars=None): # real signature unknown; restored from __doc__
        """
        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 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 strip(self, *args, **kwargs): # real signature unknown
        """
        Strip leading and trailing bytes contained in the argument.

        If the argument is omitted or None, strip leading and trailing ASCII whitespace.
        """
        pass

 

 
str.maketrans(*args, **kwargs)
# 创建对应关系
translate(self, table, deletechars=None)
# 字符替换

 

 
 
In [1]: str1="abcde"

In [2]: str2="12345"

In [3]: mre=str.maketrans(str1,str2)

In [4]: value="edcbaooooa"

In [5]: new_value=value.translate(mre)

In [6]: print(new_value)
54321oooo1

 

    def maketrans(*args, **kwargs): # real signature unknown
        """
        Return a translation table useable for the bytes or bytearray translate method.

        The returned table will be one where each byte in frm is mapped to the byte at
        the same position in to.

        The bytes objects frm and to must be of the same length.
        """
        pass
    def translate(self, table, deletechars=None): # real signature unknown; restored from __doc__
        """
        translate(table, [deletechars])
        Return a copy with each character mapped by the given translation table.

          table
            Translation table, which must be a bytes object of length 256.

        All characters occurring in the optional argument deletechars are removed.
        The remaining characters are mapped through the given translation table.
        """
        pass

 

 
 
str.partition(self, *args, **kwargs)
# 在字节中,搜索分隔符,如果搜索到
# 从左开始,返回分割符之前、分隔符、分隔符之后三个部分 str.rpartition(self, *args, **kwargs) # 在字节中,搜索分隔符,如果搜索到
# 从右开始,返回分隔符之前、分隔符、分隔符之后三个部分
str.split(self, *args, **kwargs) # 默认从左开始,分割所有除分隔符之外的字节
# 可指定分割字段
str.rsplit(self, *args, **kwargs) # 默认从右开始,分割所有除分隔符之外的字节
# 可指定分割字段
str.splitlines(self, keepends=None) # 分割换行符

 

 
 
In [1]: str="konglingchao\nkongdexian"

In [2]: print(str.partition("n"),str.rpartition("n"))
(\'ko\', \'n\', \'glingchao\nkongdexian\') (\'konglingchao\nkongdexia\', \'n\', \'\')

In [3]: print(str.split("n"),str.rsplit("n",2))
[\'ko\', \'gli\', \'gchao\nko\', \'gdexia\', \'\'] [\'konglingchao\nko\', \'gdexia\', \'\']

In [4]: print(str.splitlines(True),str.splitlines(False))
[\'konglingchao\n\', \'kongdexian\'] [\'konglingchao\', \'kongdexian\']

 

 
    def partition(self, *args, **kwargs): # real signature unknown
        """
        Partition the bytes into three parts using the given separator.

        This will search for the separator sep in the bytes. If the separator is found,
        returns a 3-tuple containing the part before the separator, the separator
        itself, and the part after it.

        If the separator is not found, returns a 3-tuple containing the original bytes
        object and two empty bytes objects.
        """
        pass
 
   def rpartition(self, *args, **kwargs): # real signature unknown
        """
        Partition the bytes into three parts using the given separator.

        This will search for the separator sep in the bytes, starting and the end. If
        the separator is found, returns a 3-tuple containing the part before the
        separator, the separator itself, and the part after it.

        If the separator is not found, returns a 3-tuple containing two empty bytes
        objects and the original bytes object.
        """
        pass

    def split(self, *args, **kwargs): # real signature unknown
        """
        Return a list of the sections in the bytes, using sep as the delimiter.

          sep
            The delimiter according which to split the bytes.
            None (the default value) means split on ASCII whitespace characters
            (space, tab, return, newline, formfeed, vertical tab).
          maxsplit
            Maximum number of splits to do.
            -1 (the default value) means no limit.
        """
        pass



    def rsplit(self, *args, **kwargs): # real signature unknown
        """
        Return a list of the sections in the bytes, using sep as the delimiter.

          sep
            The delimiter according which to split the bytes.
            None (the default value) means split on ASCII whitespace characters
            (space, tab, return, newline, formfeed, vertical tab).
          maxsplit
            Maximum number of splits to do.
            -1 (the default value) means no limit.

        Splitting is done starting at the end of the bytes and working to the front.
        """
        pass

    def splitlines(self, keepends=None): # real signature unknown; restored from __doc__
        """
        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 []

 

   
str.startswith(self, prefix, start=None, end=None)
str.endswith(self, suffix, start=None, end=None)
# 判断是否以某个字符开头或结尾

 

 
In [7]: str="konglingchao"
In [8]: print(str.startswith(\'ko\'),str.endswith(\'ao\'))
True True

 

 
    def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__
        """
        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 endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__
        """
        B.endswith(suffix[, start[, end]]) -> bool

        Return True if B ends with the specified suffix, False otherwise.
        With optional start, test B beginning at that position.
        With optional end, stop comparing B at that position.
        suffix can also be a tuple of bytes to try.
        """
        return False

 

       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       
       

 

 

 

 

 

分类:

技术点:

相关文章: