zoukankan      html  css  js  c++  java
  • python & str对象函数

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


    capitalize()函数的作用是将字符的首字符upper后返回,字符本身不变。

    
    
    
    
    1 def center(self, width, fillchar=None): # real signature unknown; restored from __doc__
    2     """
    3     S.center(width[, fillchar]) -> str
    4     
    5     Return S centered in a string of length width. Padding is
    6     done using the specified fill character (default is a space)
    7     """
    8     return center
    center
    
    
    


    center函数有3个参数,参数1默认是对象自身,参数2指定字符长度,参数3指定用什么字符填充,当字符数比参数2小时。

    
    
    1 def count(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    2     """
    3     S.count(sub[, start[, end]]) -> int
    4     
    5     Return the number of non-overlapping occurrences of substring sub in
    6     string S[start:end].  Optional arguments start and end are
    7     interpreted as in slice notation.
    8     """
    9     return 0
    
    
    


    count函数统计字符串含有参数2指定的字符的个数, 该函数的第3,第4参数可以指定在n~n>1 个字符里count。

    def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
    """
    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""
    
    
     1     def encode(self, encoding='utf-8', errors='strict'): # real signature unknown; restored from __doc__
     2         """
     3         S.encode(encoding='utf-8', errors='strict') -> bytes
     4         
     5         Encode S using the codec registered for encoding. Default encoding
     6         is 'utf-8'. errors may be given to set a different error
     7         handling scheme. Default is 'strict' meaning that encoding errors raise
     8         a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and
     9         'xmlcharrefreplace' as well as any other name registered with
    10         codecs.register_error that can handle UnicodeEncodeErrors.
    11         """
    12         return b""
    
    

    encode() 函数是将自身转换为指定代码的函数,由参数2指定。参数3是标志采用哪种纠错模式。默认strict严格模式

     1     def endswith(self, suffix, start=None, end=None): # real signature unknown; restored from __doc__
     2         """
     3         S.endswith(suffix[, start[, end]]) -> bool
     4         
     5         Return True if S ends with the specified suffix, False otherwise.
     6         With optional start, test S beginning at that position.
     7         With optional end, stop comparing S at that position.
     8         suffix can also be a tuple of strings to try.
     9         """
    10         return False
    str.endswith(suffix[, start[, end]]) 函数检查值是否结尾是否指定字符,如果是返回true,否则falase。参数2指定开始位置,参数3指定结束位置


    1     def expandtabs(self, tabsize=8): # real signature unknown; restored from __doc__
    2         """
    3         S.expandtabs(tabsize=8) -> str
    4         
    5         Return a copy of S where all tab characters are expanded using spaces.
    6         If tabsize is not given, a tab size of 8 characters is assumed.
    7         """
    8         return ""

    expandtabs 函数将字符串内的 转移符转换为8个空格。

     1     def find(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
     2         """
     3         S.find(sub[, start[, end]]) -> int
     4         
     5         Return the lowest index in S where substring sub is found,
     6         such that sub is contained within S[start:end].  Optional
     7         arguments start and end are interpreted as in slice notation.
     8         
     9         Return -1 on failure.
    10         """
    11         return 0

    str.find函数 查找指定字符串,参数2指定要查找的字符,参数3指定开始位置,参数4指定结束位置。

    1     def format(self, *args, **kwargs): # known special case of str.format
    2         """
    3         S.format(*args, **kwargs) -> str
    4         
    5         Return a formatted version of S, using substitutions from args and kwargs.
    6         The substitutions are identified by braces ('{' and '}').
    7         """
    8         pass

    str.format() 格式化函数将多个字符串格式化到自身的{}中。

    1  def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
    2         """
    3         S.index(sub[, start[, end]]) -> int
    4         
    5         Like S.find() but raise ValueError when the substring is not found.
    6         """
    7         return 0

    str.index() 函数将查找参数2指定的字符在字符串里从左到右开始出现的位置,参数3和参数4可以指定查找范围。默认缺省

    1     def isalnum(self): # real signature unknown; restored from __doc__
    2         """
    3         S.isalnum() -> bool
    4         
    5         Return True if all characters in S are alphanumeric
    6         and there is at least one character in S, False otherwise.
    7         """
    8         return False

    str.isalnum() 函数判断字符串内是否全部由数字组成的,是返回true。否则返回false

    1     def isalpha(self): # real signature unknown; restored from __doc__
    2         """
    3         S.isalpha() -> bool
    4         
    5         Return True if all characters in S are alphabetic
    6         and there is at least one character in S, False otherwise.
    7         """
    8         return False

    str.isalpha() 函数判断是否全部由字母组成,是返回true

    1     def isdecimal(self): # real signature unknown; restored from __doc__
    2         """
    3         S.isdecimal() -> bool
    4         
    5         Return True if there are only decimal characters in S,
    6         False otherwise.
    7         """
    8         return False

    str.isdecimal() 函数判断值是否全由十进制组成,是返回true,否则返回false

    1  def isdigit(self): # real signature unknown; restored from __doc__
    2         """
    3         S.isdigit() -> bool
    4         
    5         Return True if all characters in S are digits
    6         and there is at least one character in S, False otherwise.
    7         """
    8         return False

    str.isdigit() 函数判断值是否全由数字组成。

    1     def islower(self): # real signature unknown; restored from __doc__
    2         """
    3         S.islower() -> bool
    4         
    5         Return True if all cased characters in S are lowercase and there is
    6         at least one cased character in S, False otherwise.
    7         """
    8         return False

    str.islower() 函数判断值是否全由小写字母组成-》  true,else-》false

    1     def isnumeric(self): # real signature unknown; restored from __doc__
    2         """
    3         S.isnumeric() -> bool
    4         
    5         Return True if there are only numeric characters in S,
    6         False otherwise.
    7         """
    8         return False

    str.isnumeric() 函数判断值本身是否全由数字组成,针对unicode的。

    1  def isspace(self): # real signature unknown; restored from __doc__
    2         """
    3         S.isspace() -> bool
    4         
    5         Return True if all characters in S are whitespace
    6         and there is at least one character in S, False otherwise.
    7         """
    8         return False

    str.isspace() 函数判断值本身是否全由空格组成。

     1     def istitle(self): # real signature unknown; restored from __doc__
     2         """
     3         S.istitle() -> bool
     4         
     5         Return True if S is a titlecased string and there is at least one
     6         character in S, i.e. upper- and titlecase characters may only
     7         follow uncased characters and lowercase characters only cased ones.
     8         Return False otherwise.
     9         """
    10         return False

    函数判断值本身是否全部单词首字母都是大写,其他小写。是 true,否则false

    1     def isupper(self): # real signature unknown; restored from __doc__
    2         """
    3         S.isupper() -> bool
    4         
    5         Return True if all cased characters in S are uppercase and there is
    6         at least one cased character in S, False otherwise.
    7         """
    8         return False

    str.isupper() 函数判断值本身是否全部大写。

    1     def join(self, iterable): # real signature unknown; restored from __doc__
    2         """
    3         S.join(iterable) -> str
    4         
    5         Return a string which is the concatenation of the strings in the
    6         iterable.  The separator between elements is S.
    7         """
    8         return ""

    str.join() 函数可以将参数2的值和自身组合成为一个新的值,并返回。 新的值可以是list,tuple,dict。

    1  def ljust(self, width, fillchar=None): # real signature unknown; restored from __doc__
    2         """
    3         S.ljust(width[, fillchar]) -> str
    4         
    5         Return S left-justified in a Unicode string of length width. Padding is
    6         done using the specified fill character (default is a space).
    7         """
    8         return ""

    str.ljust() 函数将值左对齐后按参数1的值进行扩充,扩充部分由参数2填充。如果参数1的值小于自身长度,则返回自身。

    1  def lower(self): # real signature unknown; restored from __doc__
    2         """
    3         S.lower() -> str
    4         
    5         Return a copy of the string S converted to lowercase.
    6         """
    7         return ""
    1  def lower(self): # real signature unknown; restored from __doc__
    2         """
    3         S.lower() -> str
    4         
    5         Return a copy of the string S converted to lowercase.
    6         """
    7         return ""

    str.lower()函数将值所有大写字母转换为小写后返回

    1     def lstrip(self, chars=None): # real signature unknown; restored from __doc__
    2         """
    3         S.lstrip([chars]) -> str
    4         
    5         Return a copy of the string S with leading whitespace removed.
    6         If chars is given and not None, remove characters in chars instead.
    7         """
    8         return ""

    str.lstrip() 函数将字符串左边的换行回车符全部去掉。

     1     def maketrans(self, *args, **kwargs): # real signature unknown
     2         """
     3         Return a translation table usable for str.translate().
     4         
     5         If there is only one argument, it must be a dictionary mapping Unicode
     6         ordinals (integers) or characters to Unicode ordinals, strings or None.
     7         Character keys will be then converted to ordinals.
     8         If there are two arguments, they must be strings of equal length, and
     9         in the resulting dictionary, each character in x will be mapped to the
    10         character at the same position in y. If there is a third argument, it
    11         must be a string, whose characters will be mapped to None in the result.
    12         """
    13         pass

    str.maketrans() 函数的作用是将参数1指定的字符并且存在在本身值当中的,由参数2的对应字符逐一替换。

    1     def partition(self, sep): # real signature unknown; restored from __doc__
    2         """
    3         S.partition(sep) -> (head, sep, tail)
    4         
    5         Search for the separator sep in S, and return the part before it,
    6         the separator itself, and the part after it.  If the separator is not
    7         found, return S and two empty strings.
    8         """
    9         pass

    str.partition() 函数将参数2中指定的符号作为字符串分隔符来分割自身。

    1  def replace(self, old, new, count=None): # real signature unknown; restored from __doc__
    2         """
    3         S.replace(old, new[, count]) -> str
    4         
    5         Return a copy of S with all occurrences of substring
    6         old replaced by new.  If the optional argument count is
    7         given, only the first count occurrences are replaced.
    8         """
    9         return ""

    str.replace() 函数接收4个参数,默认参数有2个,分别为第一个隐形参数,对象自身,参数2 被替换的字符串,参数3替换的字符串,参数4指定替换多少个。

     1  def rfind(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
     2         """
     3         S.rfind(sub[, start[, end]]) -> int
     4         
     5         Return the highest index in S where substring sub is found,
     6         such that sub is contained within S[start:end].  Optional
     7         arguments start and end are interpreted as in slice notation.
     8         
     9         Return -1 on failure.
    10         """
    11         return 0

    str.rfind() 函数将从右侧开始查找,和find相反。

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

    str.rstrip() 函数将值右边的回车换行符去掉。

     1  def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
     2         """
     3         S.split(sep=None, maxsplit=-1) -> list of strings
     4         
     5         Return a list of the words in S, using sep as the
     6         delimiter string.  If maxsplit is given, at most maxsplit
     7         splits are done. If sep is not specified or is None, any
     8         whitespace string is a separator and empty strings are
     9         removed from the result.
    10         """
    11         return []

    str.split() 函数将自身切片成多个子字符串,通过参数2指定分隔符。

     1  def startswith(self, prefix, start=None, end=None): # real signature unknown; restored from __doc__
     2         """
     3         S.startswith(prefix[, start[, end]]) -> bool
     4         
     5         Return True if S starts with the specified prefix, False otherwise.
     6         With optional start, test S beginning at that position.
     7         With optional end, stop comparing S at that position.
     8         prefix can also be a tuple of strings to try.
     9         """
    10         return False

    str.startswith() 函数将判断自身是否由参数2指定的字符串开头,参数3,参数4指定开始与结束

    1     def strip(self, chars=None): # real signature unknown; restored from __doc__
    2         """
    3         S.strip([chars]) -> str
    4         
    5         Return a copy of the string S with leading and trailing
    6         whitespace removed.
    7         If chars is given and not None, remove characters in chars instead.
    8         """
    9         return ""

    str.strip() 函数将字符串左右的回车换行符去掉。

    1     def swapcase(self): # real signature unknown; restored from __doc__
    2         """
    3         S.swapcase() -> str
    4         
    5         Return a copy of S with uppercase characters converted to lowercase
    6         and vice versa.
    7         """
    8         return ""

    str.swapcase() 函数将字符串的大小写形式全部逆转。

     
  • 相关阅读:
    文件数据源设置
    维护0material主数据,提示Settings for material number conversion not found
    7.5版本COPA数据源创建转换提示“不允许对象名称为空”
    COPA指标自动创建
    IDEA操作数据库
    Docker(快速实战流程)
    Docker(理论部分小结)
    Docker数据卷挂载相关
    解决pycharm启动updating Python interpreter长时间更新
    IDEA完美配置(shell)linux的命令行工具
  • 原文地址:https://www.cnblogs.com/zxcv-/p/6799962.html
Copyright © 2011-2022 走看看