V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
tinydebian
V2EX  ›  Python

Python compileall 如何排除 2 个子目录?

  •  
  •   tinydebian · 2019-10-22 15:19:47 +08:00 · 2465 次点击
    这是一个创建于 1619 天前的主题,其中的信息可能已经有所发展或是发生改变。
    下面的命令,可以使用 python compileall,并且排除一个子目录。
    python -m compileall -x r"*/folder1*" /python-folder/

    请问,如何排除 2 个子目录呢?谢谢。
    9 条回复    2019-10-22 17:31:04 +08:00
    Latin
        1
    Latin  
       2019-10-22 15:28:09 +08:00
    自己写 compile 脚本包装下
    Cooky
        3
    Cooky  
       2019-10-22 15:43:46 +08:00 via Android
    find,grep,xargs
    tinydebian
        4
    tinydebian  
    OP
       2019-10-22 16:16:15 +08:00
    @Latin 可以借用 compileall -x (regex)的吧?只是这个 regex 稍复杂点。
    tinydebian
        5
    tinydebian  
    OP
       2019-10-22 16:16:57 +08:00
    @ihidchaos 使用 compileall -x (regex) 应该是最简洁的吧?只是这个 regex 稍复杂点。
    tinydebian
        6
    tinydebian  
    OP
       2019-10-22 16:17:55 +08:00
    @Cooky 使用 compileall -x (regex) 应该是最简洁的吧?只是这个 regex 稍复杂点。
    Latin
        7
    Latin  
       2019-10-22 16:34:03 +08:00
    看来大家都是混淆成 pyc 啊 手动滑稽
    Latin
        8
    Latin  
       2019-10-22 16:37:14 +08:00   ❤️ 1
    tinydebian
        9
    tinydebian  
    OP
       2019-10-22 17:31:04 +08:00
    @Latin 是啊,compileall 就是 byte-comile => .pyc 文件的。

    有 2 个子目录,我想排除掉( skipped )。如果只是 skip 一个子目录 -x r"*/folder1*" 工作得非常好,但是我不知道怎么写这个 regex 来排除 2 个 或 3 个 子目录。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1530 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:05 · PVG 01:05 · LAX 10:05 · JFK 13:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.