晋江文学城
下一章 上一章  目录  设置

10、2022.04.08 ...

  •   python

      3-10尝试使用各个函数存储列表:山岳、河流、国家、城市、语言
      创建列表
      使用本章函数处理列表

      3.4使用列表避免索引错误

      error 1:

      motorcycles=【*honda*,*yamaha*,*suzuki*】print(motorcycles【3】)

      error 2:

      motorcycles=【 】
      print(motorcycle【-1】)

      3-11 有意引发错误

      3.5 小结
      1什么是列表
      2使用其中的元素
      3定义列表
      4增删元素
      5永久性排序
      6临时性排序
      7确定长度
      8避免错误
      items=【‘tang’,‘yuan’,‘qing’】

      message=“The first three items in the list are:”

      for item in items【0:2】:

      print(message)
      print(item.title())

      The first three items in the list are:
      Tang
      Yuan
      Qing

  • 昵称:
  • 评分: 2分|鲜花一捧 1分|一朵小花 0分|交流灌水 0分|别字捉虫 -1分|一块小砖 -2分|砖头一堆
  • 内容:
  •             注:1.评论时输入br/即可换行分段。
  •                 2.发布负分评论消耗的月石并不会给作者。
  •             查看评论规则>>