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. NYOJ 915 +-字符串【贪心】

    +-字符串 时间限制:1000 ms  |  内存限制:65535 KB 难度:1 描写叙述 Shiva得到了两个仅仅有加号和减号的字符串,字串长度同样.Shiva一次能够把一个加号和它相邻的减号交换 ...

  2. 怎样用批处理来执行多个exe文件

    怎样用批处理来运行多个exe文件 @echo off start *****.exe start *****.exe start *****.exe start *****.exe 接着我们就能够运行 ...

  3. gpg 的使用

    GPG入门教程 GpG使用指南 1. 安装 源码编译安装:源码下载地址 ./configure make make install 直接安装编译好的二进制文件 # Debian / Ubuntu 环境 ...

  4. [JZOJ 4307] [NOIP2015模拟11.3晚] 喝喝喝 解题报告

    题目链接: http://172.16.0.132/senior/#main/show/4307 题目: 解题报告: 题目询问我们没出现坏对的连续区间个数 我们考虑从左到有枚举右端点$r$,判断$a[ ...

  5. HDU 1704 Rank【传递闭包】

    解题思路:给出n个选手,m场比赛,问不能判断胜负的询问最多有多少种 用传递闭包即可 但是如果直接用3重循环会超时 在判断d[i][j]=d[i][k]||d[k][j]是否连通的时候 可以加一个if语 ...

  6. 在 android studio 中更新安卓应用版本号

    随着应用程序不断修改,版本号也应当变化.要更新安卓应用的版本号,只需要在 build.gradle(module:app) 中修改 versionCode 和 versionName 即可,也可以只改 ...

  7. luogu P1495 曹冲养猪(中国剩余定理)

    题意 题解 翻到了一个金句 就跟这句话说得一样,就是个裸题. 所以看模板呗. #include<iostream> #include<cstring> #include< ...

  8. jquery 取页面中ifram中得节点

    <iframe src="html/bai.jsp" frameBorder=0 id=middle name=middle scrolling="yes" ...

  9. session 超时跳转登陆页面

    /** * session超时跳转登陆页面 * @author zhangdong * 2017年10月24日 */ @Aspect @Component public class SessionTi ...

  10. JAVA 程序生成jar包运行报错 Exception in thread "Thread-1" java.lang.NoClassDefFoundError: javax/xml/rpc 的解决方法

    最近开发支付宝生活缴费的项目,java程序要使用.NET 的WebService服务,后来正式部署出现这错误,网上查资料是少了一个“jaxrpc.jar”文件,但是我本地调试正常,最后是删除我目前导出 ...