0
我正在写一个Python脚本,其中的一部分功能是查找特定种类的最后修改文件。就我而言,它是在Mac OS X上的最后一次修改屏幕保护程序的plist文件下面是其对付这种代码位:Python:“OSError:[Errno 2]没有这样的文件或目录:”...找到它的文件?
import os
PlistFolder = "Library/Preferences/ByHost"
MacPlistPath = os.path.join(HomeFolder, PlistFolder)
PlistSSMac = max([f for f in os.listdir(MacPlistPath) if f.lower().endswith('.plist') and f.lower().startswith('com.apple.screensaver.')], key=os.path.getmtime)
当我运行它,但是,它给了我一个错误,而返回正是我想要它找到...
Traceback (most recent call last):
File "tcn_test.py", line 29, in <module>
MacPlistFile = max([f for f in os.listdir(MacPlistPath) if f.lower().endswith('.plist') and f.lower().startswith('com.apple.screensave
r.')], key=os.path.getmtime)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py", line 62, in getmtime
return os.stat(filename).st_mtime
OSError: [Errno 2] No such file or directory: 'com.apple.screensaver.097EBF05-D7B5-5FD6-A031-12734A82135D.plist'
任何想法是什么原因造成这种情况,我怎么能解决它?
预先感谢您!