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. 纯粹的K12精髓 - 名师指导整理《20以内加法口诀表》

    纯粹的K12精髓 - 名师指导整理<20以内加法口诀表> 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一 ...

  2. POJ 3664 Election Time 题解

    这道题网上非常多人都会说easy,水题之类的话,只是我看了下说这种话的人的程序,能够说他们的程序都不及格! 为什么呢?由于他们的程序都是使用简单的二次排序水过(大概你能搜索到的多是这种程序).那样自然 ...

  3. wikioi 1306 机智Trie树

    题目描写叙述 Description 看广播操无聊得非常~你有认为吗?在看广播操一波又一波的人潮涌过再退去.认为非常没意思--于是,偶们的大神犇JHT发明了一个及其好玩的游戏~ 把每一班级的队形看成一 ...

  4. IDE-IntelliJ IDEA

    IDE-IntelliJ IDEA 主题.字体.编辑区主题.文件编码修改.乱码问题 主题修改 上图标注 1 所示为 IntelliJ IDEA 修改主题的地方,可以通过打开左上角的File -> ...

  5. ionic2集成极光推送

    ionic2集成极光推送: ionic2api:https://ionicframework.com/docs/ 极光推送官网:https://www.jiguang.cn android-怎么注册极 ...

  6. Ubuntu16.04 Mysql

    1.安装mysql root@ubuntu:~# sudo apt-get install mysql-server root@ubuntu:~# apt install mysql-client r ...

  7. Android 常用系统服务

    WindowManager:WindowManager服务是全局的唯一的.它会将用户在屏幕上的操作发送给界面上的各个Window,Activity会将顶层控件注册到WindowManager中.Win ...

  8. Net Core链接数据库

    原文 在Windows下,相信大家分分钟都可以搞定.而初次接触.net core + mysql可能需要注意些细节.首先打开vs2017新建一个asp.net core项目(选Web应用程序), 然后 ...

  9. 一袭白衣一 IDEA的破解安装以及汉化

    DEA是一款比eclipse用起来更好用的一款代码编辑器,本人之前也是一直在用eclipse来写代码,后来发现了IDEA用起来会更顺手,所以又转用IDEA了,今天给大家分享一下IDEA的下载安装破解以 ...

  10. HDU 1312 Red and Black【DFS】

    搜索虐我千万遍@_@-----一道搜索的水题,WA了好多好多次@_@发现是n,m搞反了-_- 题意-- 给出m行 n列的矩形,其中从@出发,不能跳到#,只能跳到'.'问最多能够跳到多少块'.' 直接搜 ...