Python_16_replace

hyeong taek jo·2023년 9월 12일

Python

목록 보기
16/53

📌 replace

txt = "My password is 1234"
ret1 = txt.replace('1','0')          # 1을 0으로 변경
ret2 = txt.replace('1','python')     # 1을 python으로 변경
print(ret1)
print(ret2)

txt = "매일 많은 일들이 일어납니다."
ret3 = txt.replace('매일','항상')
ret4 = txt.replace('일', '사건')
print(ret3)
print(ret4)
profile
마포구 주민

0개의 댓글