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

请教下 Python 在 windows 上执行命令行的问题

  •  
  •   peanuts7660 · Jul 15, 2019 · 2633 views
    This topic created in 2521 days ago, the information mentioned may be changed or developed.
    我需要执行命令行来调用另一个程序 A,由于 A 在执行的过程中会启动程序 B,并且 程序 B 会一直运行,所以 即使是 程序 A 已经执行完毕,我 python 中执行的命令行还是阻塞着没有退出。
    现在执行命令行使用的是 os.popen(cmd).read() , 请问下大家有什么方法能够让 A 执行完毕,我的程序就不再阻塞?
    3 replies    2019-07-16 01:14:39 +08:00
    rabbitlbj
        1
    rabbitlbj  
       Jul 15, 2019 via Android
    os.system
    1462326016
        2
    1462326016  
       Jul 15, 2019
    理论上来说你这样的话 B 就是 A 的子进程了,除非 B 退出了,否则你这种情况下应该不能单独退出 A 让 B 单独运行。
    PlushieChicka
        3
    PlushieChicka  
       Jul 16, 2019
    为什么不用 os.system()呢?
    如果你是因为某些特殊需求要用 os.popen(cmd).read(),可以试试用多线程,多开一个线程去干这事。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1031 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 19:00 · PVG 03:00 · LAX 12:00 · JFK 15:00
    ♥ Do have faith in what you're doing.