728x90
1. string() 함수
word = 'banana'
fruit = word.replace('ban','apple')
이라 함은
banana의 ban을 apple로 바꿔주는 역할
즉 출력 값은
appleana 가 된다
여러 반복되는 글자들도
banana 의 a를 -> o를 바꾸고 출력한 값임
즉 bonono가 됨
2.strip() ,lstrip(),rstrip()함수
출력문만 봐도 바로 이해가 가듯 공백을 제거해주는 함수
strip은 왼쪽오른쪽 전부 제거
lstrip은 왼쪽 공백제거
rstrip은 오른쪽 공백제거
'공부 > 파이썬' 카테고리의 다른 글
python Data structures 8.4 list (0) | 2022.01.15 |
---|---|
Python Data Structures 3주차 (0) | 2022.01.14 |
python data structures 1주차 -string (0) | 2022.01.14 |
모두를 위한 프로그래밍 7주차 (0) | 2022.01.13 |
모두를 위한 프로그래밍 5주차 (0) | 2022.01.12 |
댓글