1 个回答|225 次阅读
如果要获取有关文件的更多信息,例如文件大小和修改时间,则可以使用该stat()方法,该方法和os.stat()一样。
>>> # 路径 path 对象
... current_file_path = Path('iterable_usages.py')
... file_stat = current_file_path.stat()
...
>>> # 获取文件大小:
... print("文件大小(Bytes):", file_stat.st_size)
文件大小(Bytes): 3531
>>> # 获取**近访问时间
... print("**近访问时间:", file_stat.st_atime)
**近访问时间: 1595435202.310935
>>> # 获取**近修改时间
... print("**近修改时间:", file_stat.st_mtime)
**近修改时间: 1594127561.3204417
请先 登录 后评论