如何关闭文件的显示

How to close the display of the file

我正在使用 os.startfile(文件名) 打开(显示)一个文件。我找不到任何命令来关闭此文件的显示。

如果有相应的命令或函数,请告诉我。

根据文档,没有办法 -- https://docs.python.org/2.7/library/os.html#os.startfile

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.

您需要恢复到 pywin。