推荐学习书目
› 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
songdg
V2EX  ›  Python

请教类似[ 0 1 2 3 4 5]如何转化成列表

  •  
  •   songdg · Jul 11, 2019 · 2645 views
    This topic created in 2634 days ago, the information mentioned may be changed or developed.
    请教类似[ 0 1 2 3 4 5]如何转化成列表
    5 replies  •  2019-07-12 14:32:13 +08:00
    songdg
        1
    songdg  
    OP
       Jul 11, 2019
    使用了 np.nonzero 生成的类似[ 0 1 2 3 4 5]如何转化成列表内置的列表
    sikariba
        2
    sikariba  
       Jul 11, 2019
    返回的是 tuple,你先 indexing 一下再掉 list 构造函数就可以了吧?有什么特殊要求吗
    Takamine
        3
    Takamine  
       Jul 11, 2019
    这个是字符串吗,字符串的话可以这样。
    s1 = "[ 0 1 2 3 4 5]"
    arr = [x for x in s1[::2][1:]]
    dongxiao
        4
    dongxiao  
       Jul 11, 2019   ❤️ 1
    @songdg #1 np.nonzero(range(1, 5))[0].tolist()
    songdg
        5
    songdg  
    OP
       Jul 12, 2019
    @dongxiao 谢谢帮助。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2749 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:10 · PVG 16:10 · LAX 01:10 · JFK 04:10
    ♥ Do have faith in what you're doing.