Python论坛  - 讨论区

标题:Re: [python-chinese] 我的土制闹钟

2005年09月28日 星期三 15:30

makeyunbad makeyunbad at gmail.com
Wed Sep 28 15:30:16 HKT 2005

>    if sys.platform == 'win32':
>        import win32api
>        win32api.ShellExecute(0, "open", filename, None, "", 0)

这里可以写成:
os.startfile(filename)

os.startfile()好像调用的就是win32api.ShellExecute()

startfile( path)

Start a file with its associated application. This acts like
double-clicking the file in Windows Explorer, or giving the file name
as an argument to the start command from the interactive command
shell: the file is opened with whatever application (if any) its
extension is associated.
startfile() returns as soon as the associated application is launched.
There is no option to wait for the application to close, and no way to
retrieve the application's exit status. The path parameter is relative
to the current directory. If you want to use an absolute path, make
sure the first character is not a slash ("/"); the underlying Win32
ShellExecute() function doesn't work if it is. Use the
os.path.normpath() function to ensure that the path is properly
encoded for Win32. Availability: Windows. New in version 2.0.

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号