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

用 Python 脚本如何实现,启动 Python 脚本的脚本,例如在 shell 中执行 “python test.py”?

  •  
  •   Matrix24 · 2014-02-20 18:24:23 +08:00 · 3085 次点击
    这是一个创建于 3718 天前的主题,其中的信息可能已经有所发展或是发生改变。
    就是用Python脚本写一个能够启动特定Python脚本的程序
    4 条回复    1970-01-01 08:00:00 +08:00
    piglei
        1
    piglei  
       2014-02-20 18:33:26 +08:00
    一般来说,subprocess可以满足你的需求:

    # -*- coding: utf-8 -*-
    import subprocess

    subprocess.call('python another.py', shell=True)
    ritksm
        2
    ritksm  
       2014-02-20 18:39:36 +08:00
    ljcarsenal
        3
    ljcarsenal  
       2014-02-20 18:50:42 +08:00
    import os
    os.system('命令')
    PotatoBrother
        4
    PotatoBrother  
       2014-02-20 19:14:21 +08:00
    os库可以满足你
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2965 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:10 · PVG 17:10 · LAX 02:10 · JFK 05:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.