PYTHON CƠ BẢN - RẤT LÀ CƠ BẢN - Trang 19

XLиG

replace(search, replace[, max])

GжEQШXGLYЦM:ɴ

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МMTLš˜RKXLи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