XLиG
replace(search, replace[, max])
GжEQШXGLYЦM:ɴ
Hд
str
=
'Hello world'
newstr
=
str.replace(
'Hello'
,
'Bye'
)
print newstr
(Sҿ hiӅn thӍ chuәi
"Bye world"
trên màn hình)
8ɳQZКXVɴGLYЦMGSR
'ɹXLВXɳQZКXVɴGжEQШXGLYЦMGSRXVSRKGLYЦMPЪRFЀRK
GɨGLKМMTLRKXLиG
find(str, beg=0
end=len(string))
&ϾXч϶YPɧZКXVɴ
0
RЎYOLɺRKXɳQVEXLɳ
XVϲZА
-1
:ɴHд
str
=
'Hello world'
print str.find(
'world'
)
(hiӅn thӍ
6
)
print str.find(
'Bye'
)
;
(hiӅn thӍ
-
1
)
,ɧQ
find()
WЌXɳQXLISXLиXрXкXVɨMUYETLϲMGжEGLYЦM