String - 문자열
2020. 9. 18. 09:47ㆍ개발자료/Python
반응형
# Trim : 앞뒤 공백 제거
str = " String "
str.lstrip() # 왼쪽 공백 제거 "String "
str.rstrip() # 오른쪽 공백 제거 " String"
str.strip() # 양쪽 공백 제거 "String"
# starswith : 문자열 시작 비교
str = "start center end"
if str.startswith("start"):
print("has start")
# endswith : 문자열 끝 비교
str = "start center end"
if str.endswith("end"):
print("has end")
반응형
'개발자료 > Python' 카테고리의 다른 글
Selenium (0) | 2020.12.14 |
---|---|
pyserial - Python Serial Port Extension (0) | 2020.10.15 |
Dictionary - 딕셔너리 (0) | 2020.04.02 |
PIP - 모듈 설치 명령어 (0) | 2020.03.16 |
[module] datetime (0) | 2020.02.01 |