V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
durden
V2EX  ›  Python

Python运行Windows Win+R(run)命令

  •  
  •   durden · Sep 5, 2012 · 5093 views
    This topic created in 4982 days ago, the information mentioned may be changed or developed.
    如下这条命令可以在Windows系统的Win+R中运行(创建outlook邮件窗口),我想在Python脚本中调用它,写法如下,但是不行,被告知outlook.exe命令不被识别,将outlook.exe文件路径写全了也不行,要怎么做呢?

    import os
    cmd = 'outlook.exe /c ipm.note /m [email protected]&subject=test%20subject&body=test%20body'
    os.system(cmd)
    5 replies    1970-01-01 08:00:00 +08:00
    clino
        1
    clino  
       Sep 5, 2012
    '"C:\Program Files\Microsoft Office\Office14\OU
    TLOOK.EXE" /c ipm.note /m "[email protected]&subject=test%20subject&body=tes
    t%20body"'
    durden
        2
    durden  
    OP
       Sep 5, 2012
    @clino 还是不行呢,提示the filename, directory name, or volume label syntax is incorrect,我检查了一切正常呀

    import os
    #cmd = r'C:\Program Files\Microsoft Office\Office12\outlook.exe /c ipm.note /m [email protected]&subject=test%20subject&body=test%20body'
    cmd = 'r"C:\Program Files\Microsoft Office\Office12\outlook.exe" /c ipm.note /m "[email protected]&subject=test%20subject&body=test%20body"'
    os.system(cmd)
    clino
        3
    clino  
       Sep 5, 2012
    汗死... 'r"XXX"'
    你这个 r 是给谁看的阿
    durden
        4
    durden  
    OP
       Sep 5, 2012
    @clino 不加r直接报错呀“'c:\program' is not recognized as an internal or external command”
    clino
        5
    clino  
       Sep 5, 2012
    话说我浪费这么多条回复干啥呢
    r'"XXX"'
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4412 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 00:08 · PVG 08:08 · LAX 17:08 · JFK 20:08
    ♥ Do have faith in what you're doing.