zoukankan      html  css  js  c++  java
  • A string is a sequence

    A string is a sequence of characters. You can access the characters one at a time with the bracket operator.

                           

    The second statement selects character number 1 from fruit and assigns it to letter. The expression in brackets is called an index. The index indicates which character in the sequence you want.

    For most people the first letter of ‘banana’ is b, not a. But for computer scientists, the index is an offset from the beginning of the string, and the offset of the first letter is zero. So b is the 0th letter (‘zero-eth’) of ‘banana’, a is the 1th letter (‘one-eth’), and n is the 2th (‘two-eth’) letter.

    You can use any expression, including variables and operators, as an index, but the value of the index has to be an integer. Otherwise you get error.

    from Thinking in Python

  • 相关阅读:
    搞一个先试试
    java map排序
    文件上传
    文件下载
    Filter过滤器
    java编写一个简单的验证码
    centos7安装mysql
    linux安装jdk,tomcat服务器
    DBUtil工具类
    mysql
  • 原文地址:https://www.cnblogs.com/ryansunyu/p/3795193.html
Copyright © 2011-2022 走看看