全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Slice?

Definition 21.2 Primary & Middle School Computer Science · 第 21 章 — Strings

A slice is a part of a string (or of a list) taken by indices: s[a:b] holds the characters from index aa up to index bb, but without bb. Without aa, the slice starts at the beginning; without bb, it goes to the end; s[::-1] walks backwards and gives the string reversed.

Think of the indices as standing between the characters: the slice [a:b] takes what lies between the marks a and b.
Think of the indices as standing between the characters: the slice [a:b] takes what lies between the marks aa and bb.
在原文中阅读 →