karlxu
V2EX  ›  问与答

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

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

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