2005年09月28日 星期三 15:30
> 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.
Zeuux © 2025
京ICP备05028076号