karlxu
V2EX  ›  问与答

Python 里的文本怎么过滤掉|(432),括弧里是数字,会随机变

  •  
  •   karlxu · Oct 11, 2016 · 1987 views
    This topic created in 3538 days ago, the information mentioned may be changed or developed.
    用正则还是什么?哪种比较快?因为文本比较大,有 10M 左右
    7 replies    2016-10-12 15:25:53 +08:00
    ldbC5uTBj11yaeh5
        1
    ldbC5uTBj11yaeh5  
       Oct 11, 2016
    10M 的话,直接用 notepad++/sublime 打开查找替换搞定。

    (要啥自行车。)
    karlxu
        2
    karlxu  
    OP
       Oct 11, 2016
    @jigloo 要用脚本的,自动化需要。。。
    heiybb
        3
    heiybb  
       Oct 11, 2016   ❤️ 1
    billion
        4
    billion  
       Oct 11, 2016   ❤️ 1
    new_str = re.sub('\|\(\d+\)', '', str)
    zhanglintc
        5
    zhanglintc  
       Oct 11, 2016   ❤️ 1
    那一部分是你要过滤掉的? 就是数字? 过滤掉的意思是删掉?
    karlxu
        6
    karlxu  
    OP
       Oct 11, 2016
    感谢 3,4 楼的朋友。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2500 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 07:14 · PVG 15:14 · LAX 00:14 · JFK 03:14
    ♥ Do have faith in what you're doing.