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

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

  •  
  •   durden · 2012-09-05 13:21:26 +08:00 · 4320 次点击
    这是一个创建于 4244 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如下这条命令可以在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 条回复    1970-01-01 08:00:00 +08:00
    clino
        1
    clino  
       2012-09-05 13:59:53 +08:00
    '"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
       2012-09-05 14:06:58 +08:00
    @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  
       2012-09-05 15:29:38 +08:00
    汗死... 'r"XXX"'
    你这个 r 是给谁看的阿
    durden
        4
    durden  
    OP
       2012-09-05 15:33:32 +08:00
    @clino 不加r直接报错呀“'c:\program' is not recognized as an internal or external command”
    clino
        5
    clino  
       2012-09-05 15:53:36 +08:00
    话说我浪费这么多条回复干啥呢
    r'"XXX"'
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   857 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:43 · PVG 05:43 · LAX 14:43 · JFK 17:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.