推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
HTTmio
V2EX  ›  Python

萌新提问: list 的参数带有 : 冒号是什么?

  •  1
     
  •   HTTmio · Sep 5, 2019 · 3245 views
    This topic created in 2637 days ago, the information mentioned may be changed or developed.
    1. content = content[1:] + content[0]

      2. filename[index:]
      
      这是两个题的 不太明白 请大佬指点
      
    peanuts7660
    peanuts7660
    Sep 5, 2019❤️1
    1
    切片。content[1:] 表示从下标为 1 开始截取列表
    slice[起始下标:截止下标:间隔]
    whusnoopy
    whusnoopy
    Sep 5, 2019❤️1
    2
    list slice

    这个还是看看语言基础吧 https://docs.python.org/3/tutorial/introduction.html#lists
    672795574
    672795574
    Sep 5, 2019❤️1
    3
    content[1:] 表示 content 下标 1 到末尾。
    content = content[1:] + content[0] 应该是想把第一个字符挪到末尾
    ``
    `>>> a = "String"
    >>> a[1:] + a[0]
    'tringS'
    ```
    Marinej
    Marinej
    Sep 5, 2019❤️1
    4
    python 的切片
    Huelse
    Huelse
    Sep 5, 2019❤️1
    5
    Python 基础-切片
    lmufc
    lmufc
    Sep 5, 2019❤️1
    6
    这不是基础么。。而且是百度就有的东西
    jowan
    jowan
    Sep 5, 2019
    7
    ![a15b4afegy1flxj9snk78j209m0drdgl.jpeg]( https://i.loli.net/2019/09/05/5NpdgjsI2ozekEi.jpg)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1092 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 23:11 · PVG 07:11 · LAX 15:11 · JFK 18:11
    ♥ Do have faith in what you're doing.