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. [Python + Unit Testing] Write Your First Python Unit Test with pytest

    In this lesson you will create a new project with a virtual environment and write your first unit te ...

  2. Navgationcontroller 的pop

    1.NavgationController pop 回来不进入viewdisload,利用原来载入的视图 不是啊,他pop回来的时候不进viewdidload 直接进去viewwillApper这种方 ...

  3. dpdk l2fwd 应用流程分析

    int MAIN(int argc, char **argv) { struct lcore_queue_conf *qconf; struct rte_eth_dev_info dev_info; ...

  4. jQuery Mobile(jqm)button的隐藏和显示,包含a标签,圆角和非圆角button

    在移动互联网时代,HTML5开发越来越收到欢迎. 于是各种HTML5的框架都出来了.因为对于jquery的熟悉,jquery mobile 为多数人选择学习的对象.我也是众多追求者之中的一个.近期一直 ...

  5. javascript系列-class7.Date对象

    1.对象   什么是对象?       对象的类型是Object.   JavaScript 中的所有事物都是对象:字符串.数值.数组.函数...   javaScript中万事万物皆对象   用官方 ...

  6. BZOJ 1898 构造矩阵+矩阵快速幂

    思路: T的最小公倍数是12 那么12以内暴力 整除12 的部分用矩阵快速幂 //By SiriusRen #include <cstdio> #include <cstring&g ...

  7. BootStrap学习(三)——重写首页之导航栏和轮播图

    1.按钮 1)帮助文档:http://v3.bootcss.com/css/#buttons 2).btn-lg..btn-sm..btn-xs可以设置按钮的不同尺寸 3).active类设置按钮的激 ...

  8. Python3.x和Python2.x的区别(转存参考)

    http://www.360doc.com/content/14/0619/23/16740871_388198818.shtml 这个星期开始学习Python了,因为看的书都是基于Python2.x ...

  9. Glidar: 一个基于OpenGL的开源实时3D传感器仿真器

    1 简介 这篇博文将介绍一个简单易用的3D传感器仿真器,可以用来模拟Lidars,立体视觉,基于时间飞行技术的ToF相机和微软的Kinect实时产生3D点云数据.Glidar仿真器并不是针对特定的某一 ...

  10. 3ds max打造诱人三维水果教程:鸭梨_3dmax教程

    本系列我们介绍用3DsMAX打造美味诱人水果的实例,入门者可以按照步骤学习简单的造型和材质设定.之前我们介绍了苹果和桔子的绘制方法,今天我们介绍的主角是——鸭梨. 进入“创建”命令面板.选择“图形”按 ...