|
|__mod__(self,value,/)
|Returnself%value.
|
|__mul__(self,value,/)
|Returnself*value.n
|
|__ne__(self,value,/)
|Returnself!
=value.
|
|__new__(*args,**kwargs)frombuiltins.type
|Createandreturnanewobject.Seehelp(type)foraccuratesignature.
|
|__repr__(self,/)
|Returnrepr(self).
|
|__rmod__(self,value,/)
|Returnvalue%self.
|
|__rmul__(self,value,/)
|Returnself*value.
|
|__sizeof__(...)
|S.__sizeof__()->sizeofSinmemory,inbytes
|
|__str__(self,/)
|Returnstr(self).
|
|capitalize(...)
|S.capitalize()->str
|
|ReturnacapitalizedversionofS,i.e.makethefirstcharacter
|haveuppercaseandtherestlowercase.
|
|casefold(...)
|S.casefold()->str
|
|ReturnaversionofSsuitableforcaselesscomparisons.
|
|center(...)
|S.center(width[,fillchar])->str
|
|ReturnScenteredinastringoflengthwidth.Paddingis
|doneusingthespecifiedfillcharacter(defaultisaspace)
printx.center(50,'_')
#************thisisaTestingString!
!
************
|
|count(...)
|S.count(sub[,start[,end]])->int
|
|Returnthenumberofnon-overlappingoccurrencesofsubstringsubin
|stringS[start:
end].Optionalargumentsstartandendare
|interpretedasinslicenotation.
printx.count('')
|encode(...)
|S.encode(encoding='utf-8',errors='strict')->bytes
|
|EncodeSusingthecodecregisteredforencoding.Defaultencoding
|is'utf-8'.errorsmaybegiventosetadifferenterror
|handlingscheme.Defaultis'strict'meaningthatencodingerrorsraise
|aUnicodeEncodeError.Otherpossiblevaluesare'ignore','replace'and
|'xmlcharrefreplace'aswellasanyothernameregisteredwith
|codecs.register_errorthatcanhandleUnicodeEncodeErrors.
|
|endswith(...)
|S.endswith(suffix[,start[,end]])->bool
|
|ReturnTrueifSendswiththespecifiedsuffix,Falseotherwise.
|Withoptionalstart,testSbeginningatthatposition.
|Withoptionalend,stopcomparingSatthatposition.
|suffixcanalsobeatupleofstringstotry.
|
|expandtabs(...)
|S.expandtabs(tabsize=8)->str
|
|ReturnacopyofSwherealltabcharactersareexpandedusingspaces.
|Iftabsizeisnotgiven,atabsizeof8charactersisassumed.
|
|find(...)
|S.find(sub[,start[,end]])->int
|
|ReturnthelowestindexinSwheresubstringsubisfound,
|suchthatsubiscontainedwithinS[start:
end].Optional
|argumentsstartandendareinterpretedasinslicenotation.
|
|Return-1onfailure.
|
|format(...)
|S.format(*args,**kwargs)->str
|
|ReturnaformattedversionofS,usingsubstitutionsfromargsandkwargs.
|Thesubstitutionsareidentifiedbybraces('{'and'}').
|
|format_map(...)
|S.format_map(mapping)->str
|
|ReturnaformattedversionofS,usingsubstitutionsfrommapping.
|Thesubstitutionsareidentifiedbybraces('{'and'}').
|
|index(...)
|S.index(sub[,start[,end]])->int
|
|LikeS.find()butraiseValueErrorwhenthesubstringisnotfound.
|
|isalnum(...)
|S.isalnum()->bool
|
|ReturnTrueifallcharactersinSarealphanumeric
|andthereisatleastonecharacterinS,Falseotherwise.
|
|isalpha(...)
|S.isalpha()->bool
|
|ReturnTrueifallcharactersinSarealphabetic
|andthereisatleastonecharacterinS,Falseotherwise.
|
|isdecimal(...)
|S.isdecimal()->bool
|
|ReturnTrueifthereareonlydecimalcharactersinS,
|Falseotherwise.
|
|isdigit(...)
|S.isdigit()->bool
|
|ReturnTrueifallcharactersinSaredigits
|andthereisatleastonecharacterinS,Falseotherwise.
|
|isidentifier(...)
|S.isidentifier()->bool
|
|ReturnTrueifSisavalididentifieraccording
|tothelanguagedefinition.
|
|Usekeyword.iskeyword()totestforreservedidentifiers
|suchas"def"and"class".
importkeyword
printkeyword.iskeyword("def")
|
|islower(...)
|S.islower()->bool
|
|ReturnTrueifallcasedcharactersinSarelowercaseandthereis
|atleastonecasedcharacterinS,Falseotherwise.
|
|isnumeric(...)
|S.isnumeric()->bool
|
|ReturnTrueifthereareonlynumericcharactersinS,
|Falseotherwise.
print"98673".isalnum()
|isprintable(...)
|S.isprintable()->bool
|
|ReturnTrueifallcharactersinSareconsidered
|printableinrepr()orSisempty,Falseotherwise.
|
|isspace(...)
|S.isspace()->bool
|
|ReturnTrueifallcharactersinSarewhitespace
|andthereisatleastonecharacterinS,Falseotherwise.
|
|istitle(...)
|S.istitle()->bool
|
|ReturnTrueifSisatitlecasedstringandthereisatleastone
|characterinS,i.e.upper-andtitlecasecharactersmayonly
|followuncasedcharactersandlowercasecharactersonlycasedones.
|ReturnFalseotherwise.
|
|isupper(...)
|S.isupper()->bool
|
|ReturnTrueifallcasedcharactersinSareuppercaseandthereis
|atleastonecasedcharacterinS,Falseotherwise.
|join(...)
|S.join(iterable)->str
|
|Returnastringwhichistheconcatenationofthestringsinthe
|iterable.TheseparatorbetweenelementsisS.
|
|ljust(...)
|S.ljust(width[,fillchar])->str
|
|ReturnSleft-justifiedinaUnicodestringoflengthwidth.Paddingis
|doneusingthespecifiedfillcharacter(defaultisaspace).
|
|lower(...)
|S.lower()->str
|
|ReturnacopyofthestringSconvertedtolowercase.
|
|lstrip(...)
|S.lstrip([chars])->str
|
|ReturnacopyofthestringSwithleadingwhitespaceremoved.
|IfcharsisgivenandnotNone,removecharactersincharsinstead.
|
|partition(...)
|S.partition(sep)->(head,sep,tail)
|
|SearchfortheseparatorsepinS,andreturnthepartbeforeit,
|theseparatoritself,andthepartafterit.Iftheseparatorisnot
|found,returnSandtwoemptystrings.
|
|replace(...)
|S.replace(old,new[,count])->str
|
|ReturnacopyofSwithalloccurrencesofsubstring
|oldreplacedbynew.Iftheoptionalargumentcountis
|given,onlythefirstcountoccurrencesarereplaced.
print"98673".replace("86","_RPLS_")
|rfind(...)
|S.rfind(sub[,start[,end]])->int
|
|ReturnthehighestindexinSwheresubstringsubisfound,
|suchthatsubiscontainedwithinS[start:
end].Optional
|argumentsstartandendareinterpretedasinslicenotation.
|
|Return-1onfailure.
|
importsys
x="thisisaTestingString!
!
"
printx
foriinxrange(len(x)):
sys.stdout.write(str(i%10))
print
printx.rfind('')
printx.rfind('',0,17)
|rindex(...)等同于上面的函数
|S.rindex(sub[,start[,end]])->int
|
|LikeS.rfind()butraiseValueErrorwhenthesubstringisnotfound.
|
|rjust(...)
|S.rjust(width[,fillchar])->str
|
|ReturnSright-justifiedinastringoflengthwidth.Paddingis
|doneusingthespecifiedfillcharacter(defaultisaspace).
|
|rpartition(...)
|S.rpartition(sep)->(head,sep,tail)
|
|SearchfortheseparatorsepinS,startingattheendofS,andreturn
|thepartbeforeit,theseparatoritself,andthepartafterit.Ifthe
|separatorisnotfound,returntwoemptystringsandS.
|
|rsplit(...)
|S.rsplit(sep=None,maxsplit=-1)->listofstrings
|
|ReturnalistofthewordsinS,usingsepasthe
|delimiterstring,startingattheendofthestringand
|workingtothefront.Ifmaxsplitisgiven,atmostmaxsplit
|splitsaredone.Ifsepisnotspecified,anywhitespacestring
|isaseparator.
|
|rstrip(...)
|S.rstrip([chars])->str
|
|ReturnacopyofthestringSwithtrailingwhitespaceremoved.
|IfcharsisgivenandnotNone,removecharactersincharsinstead.
|
|split(...)
|S.split(sep=None,maxsplit=-1)->listofstrings
|
|ReturnalistofthewordsinS,usingsepasthe
|delimiterstring.Ifmaxsplitisgiven,atmostmaxsplit
|splitsaredone.IfsepisnotspecifiedorisNone,any
|whitespacestringisaseparatorandemptystringsare
|removedfromtheresult.
|
|splitlines(...)
|S.splitlines([keepends])->listofstrings
|
|ReturnalistofthelinesinS,breakingatlineboundaries.
|Linebreaksarenotincludedintheresultinglistunlesskeepends
|isgivenandtrue.
|
|startswith(...)
|S.startswith(prefix[,start[,end]])->bool
|