첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ str 클래스의 replace 메소드를 사용해 문자열을 대체하는 방법을 보여준다.

 

▶ 예제 코드 (PY)

text = "python is powerful"

print(text.replace("p", "P")) # replace(old, new)

print(text.replace("p", "P", 1)) # replace(old, new, count)

"""
Python is Powerful
Python is powerful
"""
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요