문자열치환1 [Python] "replace", 문자열 치환하기 [Python] "replace", 문자열 치환하기 ● 내용 python에서 문자열에서 특정 구문을 다른 구문으로 치환 할 수 있다. replace 함수를 사용한다. # 사용법 # replace(바꾸고 싶은 문자열, 대체할 문자열) old_str = "개구리가 폴짝폴짝" result = old_str.replace("개구리", "두꺼비") # result = "두꺼비가 폴짝폴짝" result = old_str.replace("폴짝", "개굴") # result = "개구리가 개굴개굴" 2021. 10. 11. 이전 1 다음