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

请教 python 脚本里面在调一个 python 程序应该怎么做?

  •  
  •   phx13ye ·
    Alwayswithme · Jan 28, 2016 · 3284 views
    This topic created in 3907 days ago, the information mentioned may be changed or developed.

    before: 我现在是一个 shell 脚本

    #!/bin/sh
    
    python script.py
    sslocal
    

    after: 现在想直接在script.py里做,相当于在这个脚本后面加一行 sslocal

    #!/bin/python
    
    #blablabla
    
    sslocal
    
    7 replies  •  2016-01-28 14:40:13 +08:00
    wellsc
        1
    wellsc  
       Jan 28, 2016
    python parser?
    Ansen
        2
    Ansen  
       Jan 28, 2016   ❤️ 1
    简单粗爆用 subprocess.call
    crashguy
        3
    crashguy  
       Jan 28, 2016   ❤️ 1
    去搜索 python 下执行 shell 命令,能找到你想要的答案
    chinuno
        4
    chinuno  
       Jan 28, 2016   ❤️ 1
    subprocess.Popen
    参数比较多配置空间大。
    输入输出可以通过 subprocess.PIPE 来操作
    BOYPT
        5
    BOYPT  
       Jan 28, 2016   ❤️ 1
    os.system("python xxx.py") 粗暴
    RqPS6rhmP3Nyn3Tm
        6
    RqPS6rhmP3Nyn3Tm  
       Jan 28, 2016   ❤️ 1
    os.popen 粗暴
    phx13ye
        7
    phx13ye  
    OP
       Jan 28, 2016
    subprocess.run(['sslocal', '-c', configfile]) 解决,谢谢大家
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1422 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 16:52 · PVG 00:52 · LAX 09:52 · JFK 12:52
    ♥ Do have faith in what you're doing.