반응형
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
Tags
- list
- matplotlib
- 파이썬
- Redshift
- PANDAS
- Github
- SQL
- PySpark
- hive
- django
- gas
- Presto
- math
- string
- Google Spreadsheet
- google apps script
- Google Excel
- Tkinter
- Python
- dataframe
- numpy
- Java
- Kotlin
- PostgreSQL
- GIT
- array
- c#
- Excel
- Apache
Archives
- Today
- Total
달나라 노트
Python Basic : startswith, endswith (시작 문자 매칭하기, 끝 문자 매칭하기) 본문
Python/Python Basic
Python Basic : startswith, endswith (시작 문자 매칭하기, 끝 문자 매칭하기)
CosmosProject 2022. 2. 15. 23:01728x90
반응형
Python의 내장 함수 중 startswith과 endswith의 사용법은 아래와 같습니다.
string.startswith(text)
string.endswith(text)
어떠한 문자(string)에 적용할 수 있습니다.
startswith은 적용한 문자(string)가 text로 시작하면 True를 그렇지 않으면 False를 return합니다.
endswith은 적용한 문자(string)가 text로 시작하면 True를 그렇지 않으면 False를 return합니다.
아래는 startswith과 endswith의 예시입니다.
test_string = 'watermelon'
print(test_string.startswith('wa')) # --> True
print(test_string.startswith('wate')) # --> True
print(test_string.startswith('ate')) # --> False
print(test_string.endswith('on')) # --> True
print(test_string.endswith('lon')) # --> True
print(test_string.endswith('elo')) # --> False
728x90
반응형
'Python > Python Basic' 카테고리의 다른 글
Comments
