300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 88是python语言的整数类型_Python开发【第二篇】:Python基本数据类型

88是python语言的整数类型_Python开发【第二篇】:Python基本数据类型

时间:2023-08-18 05:35:51

相关推荐

88是python语言的整数类型_Python开发【第二篇】:Python基本数据类型

class str(basestring):

"""str(object='') ->stringReturn a nice string representation ofthe object.If the argument is a string, the return value isthe same object.

"""

def capitalize(self):

""" 首字母变大写 """

"""

S.capitalize()->stringReturn a copy of the string S with only its first charactercapitalized.

"""return""

def center(self, width, fillchar=None):

""" 内容居中,width:总长度;fillchar:空白处填充内容,默认无 """

"""

S.center(width[, fillchar]) ->stringReturn S centered in a string of length width. Padding isdone using the specified fillcharacter (default is a space)

"""return""

defcount(self, sub, start=None, end=None):

""" 子序列个数 """

"""

S.count(sub[, start[, end]]) -> int

Return the number of non-overlapping occurrences of substring sub instring S[start:end]. Optional arguments start and endare interpretedas inslice notation.

"""return 0def decode(self, encoding=None, errors=None):

""" 解码 """

"""

S.decode([encoding[,errors]]) ->object

Decodes S using the codec registeredforencoding. encoding defaultsto the default encoding. errors may be given to seta different error

handling scheme.Default is 'strict'meaning that encoding errors raise

a UnicodeDecodeError. Other possiblevalues are 'ignore' and 'replace'

as well as any other name registered with codecs.register_error that isabletohandle UnicodeDecodeErrors.

"""returnobject()

def encode(self, encoding=None, errors=None):

""" 编码,针对unicode """

"""

S.encode([encoding[,errors]]) ->object

Encodes S using the codec registeredforencoding. encoding defaultsto the default encoding. errors may be given to seta different error

handling scheme.Default is 'strict'meaning that encoding errors raise

a UnicodeEncodeError. Other possiblevalues are 'ignore', 'replace' and

'xmlcharrefreplace' as well as any other name registered withcodecs.register_error thatis able tohandle UnicodeEncodeErrors.

"""returnobject()

def endswith(self, suffix, start=None, end=None):

""" 是否以 xxx 结束 """

"""

S.endswith(suffix[, start[, end]]) ->boolReturn True if S ends withthe specified suffix, False otherwise.Withoptional start, test S beginning at that position.With optional end, stop comparing S at that position.

suffix can also be a tupleof strings totry.

"""returnFalse

def expandtabs(self, tabsize=None):

""" 将tab转换成空格,默认一个tab转换成8个空格 """

"""

S.expandtabs([tabsize]) ->stringReturn a copy of S where alltab characters are expanded using spaces.If tabsize is not given, a tab size of 8 characters isassumed.

"""return""

def find(self, sub, start=None, end=None):

""" 寻找子序列位置,如果没找到,返回-1"""

"""

S.find(sub[,start [,end]]) -> int

Return the lowest index in S where substring sub isfound,

such that subis contained within S[start:end]. Optional

arguments startand end are interpreted as inslice notation.Return -1 onfailure.

"""return 0def format(*args, **kwargs): # known special case of str.format

""" 字符串格式化,动态参数,将函数式编程时细说 """

"""

S.format(*args, **kwargs) ->stringReturn a formatted version of S, using substitutions from args andkwargs.

The substitutions are identifiedby braces ('{' and '}').

"""

pass

defindex(self, sub, start=None, end=None):

""" 子序列位置,如果没找到,报错 """

S.index(sub [,start [,end]]) -> int

Like S.find() but raise ValueError when the substring is notfound.

"""return 0def isalnum(self):

""" 是否是字母和数字 """

"""

S.isalnum()->boolReturn True if all characters inS are alphanumericand there is at least one character inS, False otherwise.

"""returnFalse

def isalpha(self):

""" 是否是字母 """

"""

S.isalpha()->boolReturn True if all characters inS are alphabeticand there is at least one character inS, False otherwise.

"""returnFalse

def isdigit(self):

""" 是否是数字 """

"""

S.isdigit()->boolReturn True if all characters inS are digitsand there is at least one character inS, False otherwise.

"""returnFalse

def islower(self):

""" 是否小写 """

"""

S.islower()->boolReturn True if all cased characters in S are lowercase and there isat least one casedcharacter inS, False otherwise.

"""returnFalse

def isspace(self):

"""

S.isspace()->boolReturn True if all characters inS are whitespaceand there is at least one character inS, False otherwise.

"""returnFalse

def istitle(self):

"""

S.istitle()->boolReturn True if S is a titlecased string and there isat least onecharacter in S, i.e. uppercase characters may onlyfollow uncased

charactersand lowercase characters only cased ones. ReturnFalse

otherwise.

"""returnFalse

def isupper(self):

"""

S.isupper()->boolReturn True if all cased characters in S are uppercase and there isat least one casedcharacter inS, False otherwise.

"""returnFalse

defjoin(self, iterable):

""" 连接 """

"""

S.join(iterable) ->stringReturn a string which is the concatenation of the strings inthe

iterable. The separatorbetween elements isS.

"""return""

def ljust(self, width, fillchar=None):

""" 内容左对齐,右侧填充 """

"""

S.ljust(width[, fillchar]) ->stringReturn S left-justified in a string of length width. Padding isdone using the specified fillcharacter (default is a space).

"""return""

deflower(self):

""" 变小写 """

"""

S.lower() ->stringReturn a copy of the string S converted tolowercase.

"""return""

def lstrip(self, chars=None):

""" 移除左侧空白 """

"""

S.lstrip([chars]) -> string or unicode

Return a copy of the string S withleading whitespace removed.If chars is given and not None, remove characters inchars instead.If chars is unicode, S will be converted to unicodebefore stripping

"""return""

def partition(self, sep):

""" 分割,前,中,后三部分 """

"""

S.partition(sep)->(head, sep, tail)

Searchfor the separator sep in S, and returnthe part before it,

the separator itself,and the part after it. If the separator is notfound,return S andtwo empty strings.

"""

pass

defreplace(self, old, new, count=None):

""" 替换 """

"""

S.replace(old, new[, count]) ->stringReturn a copy of string S with all occurrences of substringold replacedby new. If the optional argument count isgiven,only the first countoccurrences are replaced.

"""return""

def rfind(self, sub, start=None, end=None):

"""

S.rfind(sub[,start [,end]]) -> int

Return the highest index in S where substring sub isfound,

such that subis contained within S[start:end]. Optional

arguments startand end are interpreted as inslice notation.Return -1 onfailure.

"""return 0def rindex(self, sub, start=None, end=None):

"""

S.rindex(sub[,start [,end]]) -> int

Like S.rfind() but raise ValueError when the substring is notfound.

"""return 0def rjust(self, width, fillchar=None):

"""

S.rjust(width[, fillchar]) ->stringReturn S right-justified in a string of length width. Padding isdone using the specified fillcharacter (default is a space)

"""return""

def rpartition(self, sep):

"""

S.rpartition(sep)->(head, sep, tail)

Searchfor the separator sep in S, starting at the end of S, and returnthe part before it, the separator itself,and the part after it. Ifthe

separatoris not found, return two empty strings andS.

"""

pass

def rsplit(self, sep=None, maxsplit=None):

"""

S.rsplit([sep [,maxsplit]]) -> list ofstringsReturn a list of the words in the string S, using sep asthe

delimiter string, starting at theend of the string andworkingto the front. If maxsplit isgiven, at most maxsplit splits are

done.If sep is not specified or is None, anywhitespace stringisa separator.

"""return []def rstrip(self, chars=None):

"""

S.rstrip([chars]) -> string or unicode

Return a copy of the string S withtrailing whitespace removed.If chars is given and not None, remove characters inchars instead.If chars is unicode, S will be converted to unicodebefore stripping

"""return""

def split(self, sep=None, maxsplit=None):

""" 分割, maxsplit最多分割几次 """

"""

S.split([sep [,maxsplit]]) -> list ofstringsReturn a list of the words in the string S, using sep asthe

delimiter string.If maxsplit isgiven, at most maxsplit

splits are done.If sep is not specified or is None, anywhitespace stringis a separator andempty strings are removedfromthe result.

"""return []def splitlines(self, keepends=False):

""" 根据换行分割 """

"""

S.splitlines(keepends=False) -> list ofstringsReturn a list of the lines inS, breaking at line boundaries.

Line breaks arenot included inthe resulting list unless keependsis given andtrue.

"""return []def startswith(self, prefix, start=None, end=None):

""" 是否起始 """

"""

S.startswith(prefix[, start[, end]]) ->boolReturn True if S starts withthe specified prefix, False otherwise.Withoptional start, test S beginning at that position.With optional end, stop comparing S at that position.

prefix can also be a tupleof strings totry.

"""returnFalse

def strip(self, chars=None):

""" 移除两段空白 """

"""

S.strip([chars]) -> string or unicode

Return a copy of the string S with leading andtrailing

whitespace removed.If chars is given and not None, remove characters inchars instead.If chars is unicode, S will be converted to unicodebefore stripping

"""return""

def swapcase(self):

""" 大写变小写,小写变大写 """

"""

S.swapcase()->stringReturn a copy of the string S withuppercase characters

convertedto lowercase andvice versa.

"""return""

def title(self):

"""

S.title()->stringReturn a titlecased version of S, i.e. words start withuppercase

characters,allremaining cased characters have lowercase.

"""return""

def translate(self,table, deletechars=None):

"""

转换,需要先做一个对应表,最后一个表示删除字符集合

intab="aeiou"

outtab= "12345"

trantab=maketrans(intab, outtab)str = "this isstring example....wow!!!"print str.translate(trantab, 'xm')

"""

"""

S.translate(table [,deletechars]) ->stringReturn a copy of the string S, where allcharacters occurringin the optional argument deletechars are removed, andthe

remaining characters have been mapped through the given

translationtable, which must be a string of length 256 orNone.If the table argument is None, no translation is applied andthe operation simply removes the charactersindeletechars.

"""return""

defupper(self):

"""

S.upper() ->stringReturn a copy of the string S converted touppercase.

"""return""

def zfill(self, width):

"""方法返回指定长度的字符串,原字符串右对齐,前面填充0。"""

"""

S.zfill(width)->string

Pad a numeric string Swith zeros on the left, tofill a fieldof the specified width. The string S isnever truncated.

"""return""

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

pass

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

pass

def __add__(self, y):

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

pass

def __contains__(self, y):

""" x.__contains__(y)<==> y inx """

pass

def __eq__(self, y):

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

pass

def __format__(self, format_spec):

"""

S.__format__(format_spec)->stringReturn a formatted version of S as described byformat_spec.

"""return""

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): # realsignature unknown

pass

def __getslice__(self, i, j):

"""

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

Use of negative indices is notsupported.

"""

pass

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='') ->stringReturn a nice string representation ofthe object.If the argument is a string, the return value isthe same object.

# (copiedfromclass 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

pass

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

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 S in memory, inbytes """

pass

def __str__(self):

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

pass

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。