728x90
1. 공백 제거
test= " Hello World "
print("lstrip :[" + test.lstrip()+"]")
print("rstrip :[" + test.rstrip()+"]")
print("strip :[" + test.strip()="]")
# lstrip :[Hello World ]
# rstrip :[ Hello World]
# strip :[Hello World]
2. 특정 문자 제거
test= www.test.com.www
print("lstrip :[" + test.lstrip('w')+"]")
print("rstrip :[" + test.rstrip('w')+"]")
print("strip :[" + test.strip('w')="]")
# lstrip :[.test.com.www]
# rstrip :[www.test.com]
# strip :[.test.com]
'selenium > 문자열' 카테고리의 다른 글
[Python] 문자열 대체 (0) | 2022.09.18 |
---|---|
[Python] 문자열 줄바꿈 기준으로 자르기 (splitline) (0) | 2022.09.16 |
[Python] 문자열 자르기 (split) (0) | 2022.09.16 |