推荐学习书目
› 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 · 3363 views
    This topic created in 3945 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
    wellsc
    Jan 28, 2016
    1
    python parser?
    Ansen
    Ansen
    Jan 28, 2016❤️1
    2
    简单粗爆用 subprocess.call
    crashguy
    crashguy
    Jan 28, 2016❤️1
    3
    去搜索 python 下执行 shell 命令,能找到你想要的答案
    chinuno
    chinuno
    Jan 28, 2016❤️1
    4
    subprocess.Popen
    参数比较多配置空间大。
    输入输出可以通过 subprocess.PIPE 来操作
    BOYPT
    BOYPT
    Jan 28, 2016❤️1
    5
    os.system("python xxx.py") 粗暴
    RqPS6rhmP3Nyn3Tm
    RqPS6rhmP3Nyn3Tm
    Jan 28, 2016❤️1
    6
    os.popen 粗暴
    phx13ye
    phx13ye
    OP
    Jan 28, 2016
    7
    subprocess.run(['sslocal', '-c', configfile]) 解决,谢谢大家
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   922 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 21:32 · PVG 05:32 · LAX 13:32 · JFK 16:32
    ♥ Do have faith in what you're doing.