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
d0m2o08
V2EX  ›  Python

用 Python 调用批处理,如何让 Python 退出之后批处理继续运行?

  •  
  •   d0m2o08 · 2018-09-26 11:27:49 +08:00 · 1616 次点击
    这是一个创建于 2031 天前的主题,其中的信息可能已经有所发展或是发生改变。
    windows 环境,想让 python 退出之后批处理继续执行,应该怎么操作,跪求指点。
    myyou
        1
    myyou  
       2018-09-26 14:34:36 +08:00   ❤️ 1
    用 subprocess.Popen 应该可以

    ```
    import subprocess
    subprocess.Popen(cmd, shell=True)
    ```
    Qzier
        2
    Qzier  
       2018-09-27 00:36:57 +08:00 via iPhone
    不清楚,我每次运行 ffmpeg 时,python 退出,还在运行
    ltoddy
        3
    ltoddy  
       2018-09-27 14:18:32 +08:00
    ```
    import signal

    signal.signal(signal.SIGINT, handler)
    ```

    我不知道 Windows 支不支持信号, 那个 handler 是一个函数,函数里面写上 Python 退出之后你想执行的代码.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4192 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 05:19 · PVG 13:19 · LAX 22:19 · JFK 01:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.