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. 安全风控的CAP原理和BASE思想

    CAP原理最多实现两个,需要牺牲一个来满足其他两个:

  2. Gym 100733J Summer Wars 题解:灵活运用扫描线的思想

    题意: 给你n个点,m个横着的线段.你能够横移这些线段,可是这些线段的相对位置不能改变.假设一个点,在它的正上方和和正下方都有线段(包含线段的终点).则这个点被视为被"屏蔽".问通 ...

  3. 新手村,学会做人选数 https://www.luogu.org/problemnew/show/P1036

    #include<cstdio> #include<cmath> #include<string.h> using namespace std; int n,k,s ...

  4. 解决Mysql报错:PHP Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication.

    最近我更新了appserv-win32-2.5.10的 PHP 5.2版本到PHP 5.3,在调用http://localhost/phpMyAdmin/时,出现如下错误:PHP Warning:   ...

  5. Codeforces 987A. Infinity Gauntlet(手速题,map存一下输出即可)

    解法: 1.先将对应的字符串存入map. 2.然后将输入的串的second置为空. 3.输出6-n,输出map中的非空串. 代码: #include <bits/stdc++.h> usi ...

  6. Glidar测试安装

    在上一篇随笔中,我们完成了对Glidar 仿真器的概念层面的认识.接下来,我们将着手对该该仿真器进行安装测试. 1 依赖库的安装 安装环境为Windows 7 64位+Ubuntu14.04 LTS的 ...

  7. STM8S汇编代码分析

    转载:http://blog.csdn.net/u010093140/article/details/50021897使用STVD建立完汇编工程项目之后(具本建立方法可以看我的另一篇博文http:// ...

  8. React中的AES加解密请求

    引言 在我们使用React开发Web前端的时候,如果是比较大的项目和正常的项目的话,我们必然会用到加解密,之前的文章中提到.NET的一些加解密,那么,这里我就模拟一个例子: 1.后台开发API接口,但 ...

  9. Java可以远程操作服务器的协议笔记

    1.SCPClient(本地复制到远程.远程复制到本地.目前未看到可以远程操作文件) 2.SMB协议(可以远程操作文件:新增.修改) 3.SFTPv3Client(可以远程操作文件:新增.修改)

  10. HDU-2896 病毒侵袭 字符串问题 AC自动机

    题目链接:https://cn.vjudge.net/problem/HDU-2896 题意 中文题 给一些关键词和一个字符串,问字符串里包括了那几种关键词 思路 直接套模版 改insert方法,维护 ...