File System & I/O
System
os.getcwd() #返回当前工作路径
os.chdir(path) #改变路径,参数是一个字符串
os.remove(filename)#删除给定文件名的文件,参数是一个字符串
os.rmdir(dirname)#删除一个目录,参数是字符串
os.mkdir(dirname)#创建一个一层目录,参数是字符串
os.makedirs(path)#创建一个多层目录,参数是字符串
os.path.split(dirnameAndFilename) #把文件路径的目录和文件名分割,返回字符串二元组(dir,name)
os.path.abspath(curPath) #获得绝对路径
os.path.splitext(filename) #获得文件扩展名(dir_name,ext)(如("a",".jpg"))
os.path.isdir(path) #判断目录是否存在(或者说判断path是否是一个目录)
os.path.isfile(path) #判断文件是否存在
os.path.exists(path) #判断路径是否存在
os.path.join(path, file) # 拼接得到适合OS的路径
time.ctime(os.path.getatime(file))
time.ctime(os.path.getmtime(file))
time.ctime(os.path.getctime(file))std I/O
File I/O
文件IO之指针定位
Last updated