for files in os.walk("Path of a directory"):
for file in files:
print(os.path.getmtime(os.path.abspath(file)))
ディレクトリ内のすべてのファイルの変更時刻を印刷します。 なぜこのエラーが発生しますか? os.walk
ドキュメントからディレクトリをトラバースする際にエラーが発生しました。TypeError:Unicodeに強制する:文字列またはバッファが必要です。リストが見つかりません。
Traceback (most recent call last):
File "L:/script/python_scripts/dir_Traverse.py", line 7, in <module>
print(os.path.getmtime(os.path.abspath(file)))
File "C:\Python27\lib\ntpath.py", line 488, in abspath
path = _getfullpathname(path)
TypeError: coercing to Unicode: need string or buffer, list found