len is a build-in function that returns the numbers of characters in a string:

Since we started counting at zero, the last index should be 5.

Alternatively, you can use negative indices, which count backward from the end of the string. The expression fruit[-1] yields the last letter, fruit[-2] yields the second to last, and so on.

The reason for index error is that no letter in ‘banana’ with the index -10. The first letter’s index should be fruit[-6].

from Thinking in Python

String build-in function - len的更多相关文章

  1. Entity Framework 6 执行Linq to Entities异常"p__linq__1 : String truncation: max=0, len=2, value='测试'"

    场景再现 我需要查询公司名称包含给定字符串的公司,于是我写了下面的测试小例子: var condition = "测试"; var query = from b in db.Com ...

  2. String类型,Function类型

    1.String类型:  1)创建String对象:    var str=new String(s);    String(s);    参数:参数 s 是要存储在 String 对象中的值或转换成 ...

  3. c++中string::function集合

    string append() 1.直接添加另一个完整的字符串: str1.append(str2); 2.添加另一个字符串的某一段字串:    str1.append(str2, 11,  7); ...

  4. the simmon effect(in psychology) :build the function of subject_information(modify the experiment programme),before we begin the experiment

    #the real experiment for simon effect #load the library which is our need import pygame import sys i ...

  5. simon effect (psychology experiment ) : build the function of wait4key()

    ## #the real experiment for simon effect #load the library which is our need import pygame import sy ...

  6. 高精度运算专题-输出函数与字符串转数字函数(Output function and the string to number function)

    输出函数:这个函数别看它小,但浓缩的都是精华啊 作用:对于高精度的数组进行倒序输出 思路:首先从被传入的数组第一位开始,一直往前扫输出就可以了(i--) 注释:因为每个数组的第一位是用来存储这个数组的 ...

  7. JS中的PadLeft、PadRight,位数不足,自动补位,String扩展方法

    类似C#中的 PadLeft.PadRight方法 //方法一 function FillZero(p) { return new Array(3 - (p + '').length + 1).joi ...

  8. Js String 属性扩展

    String.prototype.startsWith = function (startStr) {  var d = startStr.length;  return (d >= 0 &am ...

  9. util.string.js

    ylbtech-JavaScript-util: util.string.js 字符串处理工具 1.A,JS-效果图返回顶部   1.B,JS-Source Code(源代码)返回顶部 1.B.1, ...

随机推荐

  1. Android多媒体学习六:利用Service实现背景音乐的播放

    Android同意我们使用Service组件来完毕后台任务.这些任务的同意不会影响到用户其它的交互. 1.Activity类 [java] view plaincopy package demo.ca ...

  2. Linux - Redmine使用方式 | SVN提交代码

    Redmine使用方式 | SVN提交代码 本文地址:http://blog.csdn.net/caroline_wendy RbTools 1. 安装: svn co https://dev.cxx ...

  3. STM32IAP升级-----编写IAP升级遇到的问题总结

    IAP的源代码等资料我上传了,压缩包内有12个文件.,http://download.csdn.net/detail/f907279313/7524849(要积分的辛苦收集的你们就给点积分吧) 还有还 ...

  4. 【甘道夫】Hadoop2.2.0环境使用Sqoop-1.4.4将Oracle11g数据导入HBase0.96,并自己主动生成组合行键

    目的: 使用Sqoop将Oracle中的数据导入到HBase中,并自己主动生成组合行键! 环境: Hadoop2.2.0 Hbase0.96 sqoop-1.4.4.bin__hadoop-2.0.4 ...

  5. 5分钟学会 CSS Grid 布局

    欢迎加入前端交流群交流知识&&获取视频资料:749539640 这是一篇快速介绍网站未来布局的文章. Grid 布局是网站设计的基础,CSS Grid 是创建网格布局最强大和最简单的工 ...

  6. void空类型指针

    ; double db = 120.3; void *p; p = &num; cout << *(int *)p << endl;//转换成int类型的指针,再取值 ...

  7. HDU 4609 FFT+各种分类讨论

    思路: http://www.cnblogs.com/kuangbin/archive/2013/07/24/3210565.html 其实我是懒得写了.... 一定要define int long ...

  8. android实现自动安装

    安装: String str = "/CanavaCancel.apk"; String fileName = Environment.getExternalStorageDire ...

  9. IDEA模板设置

    /**   * @className: $CLASSNAME$   * @author: liuyachao   * @date: $DATE$ $TIME$ */ ================= ...

  10. MySQL表不能修改、删除等操作,卡死、锁死情况的处理办法。

    MySQL如果频繁的修改一个表的数据,那么这么表会被锁死.造成假死现象. 比如用Navicat等连接工具操作,Navicat会直接未响应,只能强制关闭软件,但是重启后依然无效. 解决办法: 首先执行: ...