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

求教 python 如何打开一个 cmd 窗口并定位到特定的目录

  •  
  •   juventusryp · Aug 15, 2016 · 11961 views
    This topic created in 3712 days ago, the information mentioned may be changed or developed.
    我想让通过 python 实现打开一个 cmd 窗口,并直接定位到某个目录

    发现使用:
    os.system('C:\\WINDOWS\\system32\\cmd.exe && cd/d G:\\123')

    可以打开 cmd 窗口但是只是定位到这个 python 文件所在的目录,并没有执行后面的 cd 命令

    求教解决方法。
    4 replies  •  2016-08-15 16:28:06 +08:00
    ahcat
        1
    ahcat  
       Aug 15, 2016
    cmd /k cd /d g:\123
    wartime
        2
    wartime  
       Aug 15, 2016
    os.chdir('G:\\123')
    os.system('C:\\WINDOWS\\system32\\cmd.exe')
    juventusryp
        3
    juventusryp  
    OP
       Aug 15, 2016
    @ahcat 试了下 貌似不可以 不过还是感谢
    juventusryp
        4
    juventusryp  
    OP
       Aug 15, 2016
    @wartime 谢谢 已经解决!
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3247 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:24 · PVG 20:24 · LAX 05:24 · JFK 08:24
    ♥ Do have faith in what you're doing.