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

a.py 调用 b.py, 只是调用不等待 b.py 的运行结束,如何实现?

  •  
  •   meloncrashed · Nov 21, 2015 · 4360 views
    This topic created in 3968 days ago, the information mentioned may be changed or developed.
    7 replies  •  2015-11-21 17:15:04 +08:00
    Orzzzz
        1
    Orzzzz  
       Nov 21, 2015
    这不就是多进程嘛?
    aborn
        2
    aborn  
       Nov 21, 2015
    要是 js 就简单了,就是一个简单的异步调用。
    virusdefender
        3
    virusdefender  
       Nov 21, 2015
    celery
    cheneydog
        4
    cheneydog  
       Nov 21, 2015   ❤️ 1
    ```python
    #! /usr/bin/env python
    # -*- coding: utf-8 -*-

    import os
    from multiprocessing import Process,freeze_support

    def task():
    os.system('python b.py')


    if __name__ == '__main__':
    freeze_support()
    Process(target=task).start()
    print "i am over"
    ```
    weifengzi2009
        5
    weifengzi2009  
       Nov 21, 2015   ❤️ 1
    a 里面调用之后不要 join 就可以了,如果 join 了就是等 b 结束完才继续执行 a
    Valyrian
        6
    Valyrian  
       Nov 21, 2015 via iPhone   ❤️ 1
    python 的 os, subprocess, multiprocessing 模块都可以实现
    knightdf
        7
    knightdf  
       Nov 21, 2015
    太多方法了。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3469 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 00:14 · PVG 08:14 · LAX 17:14 · JFK 20:14
    ♥ Do have faith in what you're doing.