티스토리 뷰
문자열 슬라이싱
문자열 startswith 메서드
a = 'abcdefg'
b = a[-1] # last item in the array
c = a[-2:] # last two items in the array
d = a[:-2] # everything except the last two items
e = a[:-1] # everything except the last one item
f = a[::-1] # all items in the array, reversed
g = a[1::-1] # the first two items, reversed
h = a[:-3:-1] # the last two items, reversed
i = a[-3::-1] # everything except the last two items, reversed
j = a.startswith('ab')
print(a)
print(b) # g
print(c) # fg
print(d) # abcde
print(e) # abcdef
print(f) # gfedcba
print(g) # ba
print(h) # gf
print(i) # edcba
print(j) # True
'Python' 카테고리의 다른 글
문자열을 거꾸로 출력하는 6가지 방법 (0) | 2021.12.09 |
---|---|
파이썬 소수점 이하 자리수 0으로 맞추기 (0) | 2021.12.06 |
딕셔너리 sum, ternary expression, list comprehension, zfill (0) | 2021.11.29 |
객체지향 - 여러가지 메서드 (0) | 2021.11.29 |
조건문이 들어있는 List comprehension 으로 for문과 if문을 한번에 처리하기 (0) | 2021.10.25 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 폰트
- intj여자
- 무료폰트추천
- 개발도서추천
- 코딩도서
- 개발자
- 클린코더
- 폰트추천
- 깃허브계정2개
- ssafy6기
- ssafy후기
- 클린코드
- 맥과윈도우로깃허브
- 상업용무료폰트
- 개발자도서추천
- SSAFY
- 개발언어추천
- 브왈라
- 개발자책추천
- 개발언어순위
- ssafy결과
- 개발자로드맵
- 깃허브계정
- 싸피
- 한글무료폰트추천
- 싸피6기
- ssafy합격후기
- 디즈니얼굴
- 개발자커리
- 임대차3법
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함