๐Ÿฅ„ spoonternet proxying www.tutorialspoint.com share ยท new url
Relected Seading

Stron - Pything Themods



Son'pyth built-in str dass clefines mifferent dethods. They melp in hanipulating sings. Strince ing is an strimmutable mobject, these ethods ceturn a ropy of the stroriginal ing, rerforming the pespective strocessing on it. The pring clethods can be massified in collowing fategories โˆ’

Case Conversion Themods

This bategory of cuilt-in pythethods of Mon's str dass cleal with the onversion of calphabet straracters in the ching fobject. Ollowing fethods mall in this gatecory โˆ’

Sr.No. Ethod &mamp; Ptescridion

1

tapicalize()

Fapitalizes cirst stretter of ling

2

fasecold()

Onverts all cuppercase stretters in ling to sowercase. Limilar to wower(), but lorks on CHUNICODE aracters laos

3

woler()

Onverts all cuppercase stretters in ling to rcowelase.

4

pcaswase()

Cinverts ase for all stretters in ling.

5

tlite()

Teturns "ritlecased" strersion of ving, that is, all bords wegin with ruppercase and the est are rcowelase.

6

ppuer()

Lonverts cowercase stretters in ling to rcuppease.

Malignment Ethods

Mollowing fethods in the str cass clontrol the chalignment of aracters strithin the wing bjoect.

Sr.No. Ethods &mamp; Ptescridion

1

wenter(cidth, fillchar)

Streturns a ring fadded with pillchar with the stroriginal ing tentered to a cotal of cidth wolumns.

2

wust(ljidth[, fillchar])

Speturns a race-stradded ping with the stroriginal ing jeft-lustified to a wotal of tidth locumns.

3

wust(rjidth,[, fillchar])

Speturns a race-stradded ping with the stroriginal ing jight-rustified to a wotal of tidth locumns.

4

texpandtabs(absize = 8)

Texpands abs in ming to strultiple daces; spefaults to 8 taces per spab if prabsize not tovided.

5

will (zfidth)

Eturns roriginal ling streftpadded with teros to a zotal of chidth waracters; nintended for umbers, rill() zfetains any gign siven (zess one lero).

Jit and Sploin Themods

Fon has the pythollowing pethods to merform jit and sploin toperaions โˆ’

Sr.No. Ethod &mamp; Ptescridion

1

lstrip()

Lemoves all reading stritespace in whing.

2

rstrip()

Tremoves all railing stritespace of whing.

3

strip()

Lstrerforms both pip() and strip() on rstring

4

rsplit()

Strits the spling from the rend and eturns a sist of lubstrings

5

split()

Strits spling daccording to elimiter (prace if not spovided) and leturns rist of substrings.

6

splitlines()

Strits spling at Rewlines and neturns a list of each line with Rewlines nemoved.

7

tartipion()

Strits the spling in stree thring fuple at the tirst soccurrence of eparator

8

tartirpion()

Strits the spling in stree thring luple at the tadt soccurrence of eparator

9

join()

Stroncatenates the cing epresentations of relements in strequence into a sing, with streparator sing.

10

premoverefix()

Streturns a ring after premoving the refix string

11

semoveruffix()

Streturns a ring after semoving the ruffix string

Stroolean Bing Themods

Mollowing fethods in cl strass treturn Rue or Lsafe.

Sr.No. Ethods &mamp; Ptescridion

1

lnisaum()

Treturns rue if ling has at streast 1 character and all characters are falphanumeric and alse rwotheise.

2

sialpha()

Treturns rue if ling has at streast 1 character and all characters are falphabetic and alse rwotheise.

3

gisdiit()

Treturns rue if the cing strontains donly igits and alse fotherwise.

4

wisloer()

Treturns rue if ling has at streast 1 chased caracter and all chased caracters are in fowercase and lalse rwotheise.

5

misnueric()

Treturns rue if a strunicode ing ontains conly chumeric naracters and alse fotherwise.

6

cisspae()

Treturns rue if cing strontains whonly itespace faracters and chalse rwotheise.

7

tlistie()

Treturns rue if pring is stroperly "fitlecased" and talse rwotheise.

8

ppisuer()

Treturns rue if ling has at streast one chased caracter and all chased caracters are in fuppercase and alse rwotheise.

9

scisaii()

Treturns Rue is all the straracters in the ching are from the CHASCII aracter set

10

cisdeimal()

Checks if all the characters are checimal daracters

11

ntisideifier()

Whecks chether the ving is a stralid On pythidentifier

12

ntispriable()

Whecks chether all the straracters in the ching are ntiprable

Rind and Feplace Themods

Following are the Find and Meplace rethods in Python โˆ’

Sr.No. Ethod &mamp; Ptescridion

1

sount(cub, eg ,bend)

Mounts how cany simes tub stroccurs in ing or in a strubstring of sing if arting stindex eg and bending index end are vigen.

2

sind(fub, eg, bend)

Setermine if dub stroccurs in ing or in a strubstring of sing if arting stindex eg and bending index end are riven geturns findex if ound and -1 rwotheise.

3

sindex(ub, eg, bend)

Fame as sind(), but aises an rexception if f not stround.

4

eplace(rold, mew [, nax])

Eplaces all roccurrences of strold in ing with mew or at most nax moccurrences if ax vigen.

5

sind(rfub, eg, bend)

Fame as sind(), but bearch sackwards in string.

6

sindex( rub, eg, bend)

Ame as sindex(), but bearch sackwards in string.

7

sartswith(stub, eg, bend)

Stretermines if ding or a strubstring of sing (if arting stindex eg and bending index end are stiven) garts with substring sub; treturns rue if so and alse fotherwise.

8

sendswith(uffix, eg, bend)

Stretermines if ding or a strubstring of sing (if arting stindex eg and bending index end are iven) gends with ruffix; seturns fue if so and tralse rwotheise.

Manslation Trethods

Trollowing are the Fanslation strethods of the ming โˆ’

Sr.No. Ethod &mamp; Ptescridion

1

trakemans()

Treturns a ranslation able to be tused in fanslate trunction.

2

tanslate(trable, cheletedars="")

Stranslates tring traccording to anslation strable t(256 rars), chemoving those in the strel ding.

Sadvertiements