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

re.split(pattern, text)的 pattern 是很长很长的 list,效率会很低吧,有什么好的方法

  •  
  •   forelegance · Apr 24, 2018 · 3002 views
    This topic created in 3125 days ago, the information mentioned may be changed or developed.

    现在又一个十几万个基因的名字,需要在一段文字中找到这些基因 Gene Symbol,然后从这个 Gene Symbol 两边切一刀,把这段文字切成 list

    但是这个 pattern 就会操集长,想到用 re.split 来弄,但是 pattern 太长了,效率低

    4 replies  •  2018-04-25 02:58:33 +08:00
    layorlayor
    layorlayor
    Apr 24, 2018
    1
    手写个 AC 自动机?
    neosfung
    neosfung
    Apr 24, 2018 via iPhone
    2
    FlashText 了解一下?
    bantao
    bantao
    Apr 24, 2018
    3
    flashtext 中文好用吗,是不是要先分个词
    laqow
    laqow
    Apr 25, 2018 via Android
    4
    re 按行操作的话不会很长,python 自己的函数处理文字非常慢,按二进制读文字做匹配速度会快很多
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1119 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:28 · PVG 02:28 · LAX 10:28 · JFK 13:28
    ♥ Do have faith in what you're doing.