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. Android 中文字体的设置方法和使用技巧

    Android TextView字体颜色等样式具体解释连接:http://blog.csdn.net/pcaxb/article/details/47341249 1.使用字体库(自己定义字体的使用) ...

  2. mysql的查询练习1

    1.多表查询

  3. iOS7实现带文本输入框的UIAlertView及获取TextField文本内容

    if (customAlertView==nil) { customAlertView = [[UIAlertView alloc] initWithTitle:@"自定义服务器地址&quo ...

  4. m_Orchestrate learning system---九、在无法保证是否有图片的情况下,如何保证页面格式

    m_Orchestrate learning system---九.在无法保证是否有图片的情况下,如何保证页面格式 一.总结 一句话总结:都配上默认缩略图就可以解决了 1.如何获取页面get方式传过来 ...

  5. hdoj--3666--THE MATRIX PROBLEM(差分约束+SPFA深搜)

    THE MATRIX PROBLEM Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  6. POJ 2132 暴搜OR Floyd

    题意: 给你一个邻接矩阵(n<=25)问所有1到2路径的gcd的lcm是多少. 一些经验(WA/TLE的经验): 1. 无脑暴搜 是会TLE的--. 2. 关于精度 dyf神牛说了:long l ...

  7. ksh简介

    -- Start 什么是 Shell 如果把 Linux 比作一个蛋,那么 Shell 就是蛋壳,我们需要通过 Shell 来使用系统. Shell 的种类 最早的 Shell 是 Bourne Sh ...

  8. 微信重排版 URL

    http://qbview.url.cn/getResourceInfo?appid=62&url=https%3A%2F%2Fcodepen.io%2Fbenjamminf%2Ffull%2 ...

  9. C语言中的作用域、链接属性与存储属性

    C语言中的作用域.链接属性与存储属性 一.作用域(scope) 代码块作用域 表示{}之间的区域,下例所示,a可以在不同的代码块里面定义. #include<stdio.h> int ma ...

  10. POJ 1821 Fence(单调队列优化DP)

    题解 以前做过很多单调队列优化DP的题. 这个题有一点不同是对于有的状态可以转移,有的状态不能转移. 然后一堆边界和注意点.导致写起来就很难受. 然后状态也比较难定义. dp[i][j]代表前i个人涂 ...