码迷,mamicode.com
首页 > 其他好文 > 详细

String slices

时间:2014-06-23 00:53:23      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   tar   com   2014   

String slices

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

bubuko.com,布布扣                       

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.

 bubuko.com,布布扣

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,布布扣,bubuko.com

String slices

标签:style   blog   http   tar   com   2014   

原文地址:http://www.cnblogs.com/ryansunyu/p/3799874.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!