zoukankan      html  css  js  c++  java
  • python学习笔记

    1、字符串表示:‘’abc‘’ 或 ‘abc’ 或 str("abc")

    2、取值-从0开始   str = "string"  str[0] --> 's'

    3、截取-从1开始计数 str[a,b]---取第a+1个到第b个字符 即“前开后闭” (a,b]   ---截取不会改变原字符串

        例如 str[1,5]---->"trin"

        

    4、for循环可以遍历任何序列的项目,如一个列表或者一个字符串、数组等都算有序列的东西

        遍历方式有两种:一种是通过索引遍历(借助内置函数 len() 和 range())

          fruits = ['banana', 'apple', 'mango']

          for index in range(len(fruits)):

          print ('当前水果 :', fruits[index])

          print ("Good bye!")

          一种是不通过索引,直接输出子元素的值

          fruits = ['banana''apple''mango']

          for index in fruits:

          print ('当前水果 :', index)

          print ("Good bye!")

      

  • 相关阅读:
    Product of Array Except Self
    Sliding Window Maximum
    First Bad Version
    Perfect Squares
    IPsec Note
    BGP实验第9-10选路原则
    BGP选路第3条原则
    BGP选路原则第1条至第8条
    BGP选路原则笔记 Cyrus
    Lab Block hole of BGP
  • 原文地址:https://www.cnblogs.com/cui-ting/p/14437033.html
Copyright © 2011-2022 走看看