您的位置:首页 > 编程语言 > Python开发

Python学习-34.Python中os模块的一些方法(二)

2014-09-29 19:10 459 查看
stat方法:

用于获取文件信息,例如创建时间、文件大小等。

import os
filestate=os.stat("e:/temp/test.txt")
print(filestate.st_mtime)# 文件最后修改的时间距离1970/1/1的秒数。

import time
print(time.localtime(filestate.st_mtime))# 一个元组,含年月日时分秒毫秒。

print(filestate.st_size)# 文件大小,按字节计数。


path.realpath方法:

import os
print(os.getcwd())
print(os.path.realpath('test.txt'))


效果相当于将realpath方法的参数与当前工作目录组合起来。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: