String slices

A segment of a string is called a slice. Selecting a slice is similar selecting a character:

The operator [n:m] returns the part of the string from the ‘n-eth’ character to the ‘m-eth’ character, including the first but excluding the last.

If you omit the first index (before the colon), the slice starts at the beginning of the string. If you omit the second index, the slice goes to the end of the string.

If the first index is greater than or equal to the second the result is an empty string. An empty sting contains no characters and has length 0, but other than that, it is the same as any other string.

from Thinking in Python

String slices的更多相关文章

  1. Go Slices: usage and internals

    Introduction Go's slice type provides a convenient and efficient means of working with sequences of ...

  2. 17 Go Slices: usage and internals GO语言切片: 使用和内部

    Go Slices: usage and internals  GO语言切片: 使用和内部 5 January 2011 Introduction Go's slice type provides a ...

  3. Think Python - Chapter 8 - Strings

    8.1 A string is a sequenceA string is a sequence of characters. You can access the characters one at ...

  4. codeigniter使用mongodb/redis

    ci2.x版本,使用mongodb,需要安装pecl-php-mongo扩展(github上很多扩展已不可用,找到个可用版本纪录于此),添加到php.ini中 使用如下 public function ...

  5. Span<T>

    Introduction Span<T> is a new type we are adding to the platform to represent contiguous regio ...

  6. Python学习笔记3-string

    More on Modules and their Namespaces Suppose you've got a module "binky.py" which contains ...

  7. 《Think Python》第8章学习笔记

    目录 8.1 字符串是一个序列(A string is a sequence) 8.2 len 8.3 用一个 for 循环进行遍历(Traversal with a for loop) 8.4 字符 ...

  8. 2.6 Rust Slice Type

    字符串操作 fn first_word(s: &String) -> usize { let bytes = s.as_bytes(); for (i, &item) in by ...

  9. Golang高效实践之array、slice、map

    前言 Golang的slice类型为连续同类型数据提供了一个方便并且高效的实现方式.slice的实现是基于array,slice和map一样是类似于指针语义,传递slice和map并不涉及底层数据结构 ...

随机推荐

  1. 数据结构 - 树形选择排序 (tree selection sort) 具体解释 及 代码(C++)

    树形选择排序 (tree selection sort) 具体解释 及 代码(C++) 本文地址: http://blog.csdn.net/caroline_wendy 算法逻辑: 依据节点的大小, ...

  2. 开源ETL工具kettle--数据迁移

    背景 因为项目的需求,须要将数据从Oracle迁移到MSSQL,不是简单的数据复制,而是表结构和字段名都不一样.甚至须要处理编码规范不一致的情况,例如以下图所看到的 watermark/2/text/ ...

  3. Java 定制工具库 —— Print(import static)

    创建自己的工具库以减少或消除重复的程序代码.例如,我们在Print类中,对常常用到的System.out.println()封装调用以减少输入负担.这样,我们在使用该类时,可以用一个更具可读性的 im ...

  4. ubuntu12.04下CKermit与开发板交互环境搭建

    CKermit蛮好的一个调试工具!就像在windows下的telnet,但是还是折腾了一下,现在看来,非常容易,其实我主要是在开发板为正常工作的情况下,以为是CKermit的问题,其实是我开发板开机设 ...

  5. Java多线程编程模式实战指南(二):Immutable Object模式--转载

    本文由本人首次发布在infoq中文站上:http://www.infoq.com/cn/articles/java-multithreaded-programming-mode-immutable-o ...

  6. CCS+C6678LE开发记录11:多核协作(IPC)入门

    为更好地发挥C6678的多核性能,需要用到多核协作.幸运的是,我们可以使用官方提供的IPC模块. IPC=Inter-Processor Communication, 核间通信,粗略来说就是多核之间进 ...

  7. inkscape

    最近的论文需要把latex公式放到图里,于是想起了装了之后一直没怎么用的inkscape.因为visio貌似没法直接贴latex格式的公式. 找了几个用法: http://blog.sciencene ...

  8. MSSQL读取xml字符串到临时表

    DECLARE @hdoc int DECLARE @doc xml SET @doc ='<CityValueSet> <CityItem> <CityId>20 ...

  9. 51nod-1134 最长递增子序列,用线段树将N^2的dp降到NlogN

    题目链接 给出长度为N的数组,找出这个数组的最长递增子序列.(递增子序列是指,子序列的元素是递增的) 例如:5 1 6 8 2 4 5 10,最长递增子序列是1 2 4 5 10. Input 第1行 ...

  10. css3实现轮播图

    css3动画属性简写: animation: name  duration  timing-function  delay  iteration-count  direction  fill-mode ...