0001aboutSTR.docx
- 文档编号:8774107
- 上传时间:2023-02-01
- 格式:DOCX
- 页数:16
- 大小:28.29KB
0001aboutSTR.docx
《0001aboutSTR.docx》由会员分享,可在线阅读,更多相关《0001aboutSTR.docx(16页珍藏版)》请在冰豆网上搜索。
0001aboutSTR
----
延时输出内容
#coding:
utf-8
importsys
importtime
out=sys.stdout.write
defpr(aString):
foriinaString:
out(i)
time.sleep(0.01)
str文档
>>>help(str)
Helponclassstrinmodulebuiltins:
classstr(object)
|Methodsdefinedhere:
|
|__add__(self,value,/)
|Returnself+value.
|__contains__(self,key,/)
|Returnkeyinself.
x="thisisaTestingString!
!
"
printx.__add__("hello")
printx.__contains__("isaTest")
|__eq__(self,value,/)
|Returnself==value.
|
|__format__(...)
|S.__format__(format_spec)->str
|
|ReturnaformattedversionofSasdescribedbyformat_spec.
|
|__ge__(self,value,/)
|Returnself>=value.
|
|__getattribute__(self,name,/)
|Returngetattr(self,name).
|
|__getitem__(self,key,/)
|Returnself[key].
|
|__getnewargs__(...)
|
|__gt__(self,value,/)
|Returnself>value.
|
|__hash__(self,/)
|Returnhash(self).
|
|__iter__(self,/)
|Implementiter(self).
|
|__le__(self,value,/)
|Returnself<=value.
|
|__len__(self,/)
|Returnlen(self).
|
|__lt__(self,value,/)
|Returnself | |__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 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 0001 aboutSTR
![提示](https://static.bdocx.com/images/bang_tan.gif)