Posts Python 语法
Post
Cancel

Python 语法

Python 语法

数组索引

a[start:end] # items start through end-1

a[start:] # items start through the rest of the array

a[:end] # items from the beginning through end-1

a[:] # a copy of the whole array

a[-1] # last item in the array

a[-2:] # last two items in the array

a[:-2] # everything except the last two items

a[::stride] # [a[0], a[stride], …, a[-1]]

a[low::stride] # [a[low], a[low+stride], …, a[-1]]

a[:high:stride] # [a[0], a[stride], …, a[high-1]]

a[low:high:stride] # [a[low], a[low+stride], …, a[high-1]]

a[::-stride] # [a[-1], a[-1-stride], …, a[0]]

a[high::-stride] # [a[high], a[high-stride], …, a[0]]

a[:low:-stride] # [a[-1], a[-1-stride], …, a[low+1]]

a[high:low:-stride] # [a[high], a[high-stride], …, a[low+1]]

This post is licensed under CC BY 4.0 by the author.

Leet Code Problem

LearnOpenGL