//=$secondUrl?>
Python
튜플 자르기 tuple slicing 튜플 슬라이싱
튜플 자르기 tuple slicing 튜플 슬라이싱
이번엔 튜플을 자르는 방법에 대해 알아보겠습니다.
이것을 시퀀스 슬라이싱(sequence slicing)이라고 부릅니다.
예를 들어서 (0,1,2,3,4,5)에서 (0,1,2,3)만 자른다던지 (3,4,5) 만 자른다던지 할 수 있습니다.
사용방법은 앞에서 했던 문자열을 슬라이싱하는 방법과 같습니다.
문자열 슬라이싱 보기튜플 슬라이싱 적용하기
myTuple = (0,1,2,3,4,5) myTuple[시작할 인덱스 이상 :끝날 인덱스 미만]
그럼 0에서 2까지 해봅시다. 2인덱스는 미만이기 때문에 0,1이 나옵니다.
myTuple = (0,1,2,3,4,5) print(myTuple[0:2])
결과는 바로 아래에서 확인할 수 있습니다.

슬라이싱의 규칙을 그대로 따르기 때문에 시작값, 끝값을 작성하지 않으면 전부다 표시합니다.
myTuple = (0,1,2,3,4,5) print(myTuple[:])
결과는 바로 아래에서 확인할 수 있습니다.

시작값만 3 넣어보겠습니다.
myTuple = (0,1,2,3,4,5) print(myTuple[3:])
결과는 바로 아래에서 확인할 수 있습니다.

끝값만 3을 넣어보겠습니다.
myTuple = (0,1,2,3,4,5) print(myTuple[:3])
결과는 바로 아래에서 확인할 수 있습니다.

//=$langList['bottomThankyou'][$langMode]?>