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
- MRI
- sample rows
- Knowledge Distillation
- Excel
- noise contrast estimation
- 3d medical image
- fastapi
- clip intensity values
- pulloff
- Actor-Critic
- Policy Gradient
- non parametic softmax
- sidleup
- shadowing
- REINFORCE
- loss functions
- normalization
- straightup
- rest-api
- 자료구조
- objective functions for machine learning
- freebooze
- resample
- remove outliers
- scowl
- domain adaptation
- model-free control
- Inorder Traversal
- checkitout
- thresholding
Archives
- Today
- Total
Let's Run Jinyeah
[Python] List - Negative Slicing 본문
List slicing notation
a[start_index : stop_index]
a[start_index : stop_index : step_size]
- 리스트의 가장 처음부터 or 마지막까지를 슬라이싱할 경우 start_index 또는 stop_index 생략 가능
- 슬라이싱 결과는 (stop_index-1)번째 원소까지 포함 (stop_index의 item은 제외)
List slicing with negative index and negative step value
# negative start or stop index
a[-1] # 마지막 item
a[-2:] # 마지막에서 두번째 item부터 마지막 item까지
a[:-2] # 처음부터 마지막에서 두번째 item 전까지
# negative step size
a[::-1] # 마지막 item을 시작으로 처음 item까지(reversed)
a[1::-1] # 앞에서 두번째 item과 첫번째 item
# negative start or stop index with negatvie step_size
a[:-3:-1] # 마지막 item과 마지막에서 두번째 item
a[-3::-1] # 마지막에서 세번째 item부터 처음 item까지
step_size가 음수일 경우 슬라이싱의 첫번째의 아이템은 리스트의 마지막 아이템이 된다. 즉, start_index가 생략된 경우(ex. a[:-3:-1]), 마지막부터 슬라이싱이 시작된다. 따라서 슬라이싱 결과는 start_index부터 reversed된 리스트이다.
'Programming > Python' 카테고리의 다른 글
| [Python] Read/Write csv file (csv, Pandas) (0) | 2022.05.25 |
|---|---|
| [Python] Modify DICOM image and save as DICOM (0) | 2022.05.19 |
| [Python] 가상환경 생성 및 활성화 (0) | 2022.05.17 |
| [Python] List method (0) | 2021.10.19 |
| Python Input - map함수, readline함수 (0) | 2021.01.22 |
Comments