- os.path.abspath(path) #返回绝对路径
- os.path.basename(path) #返回文件名
- os.path.commonprefix(list) #返回List(多个路径)中,所有path共有的最长的路径。(但是好多Python版本不支持,我是室友的anconda版本的python3.6.4就可以,我的python3.6.7就不行)
- os.path.dirname(path) #返回文件路径
- os.path.exists(path) #路径存在则返回true,路径损坏返回false
- os.path.lexists(path) #路径存在则返回true,路径损坏也返回true
- os.path.expanduser(path) #把path中包含的“”和“user”转换成用户目录
- os.path.expandvars(path) #根据环境变量的值替换path中包含“ n a m e ” 和 “ name”和“ name”和“{name}”
- os.path.getatime(path) #返回在此path下最后一次访问path的时间
- os.path.getmtime() #返回在此path下最后一次修改的时间
- os.path.isfile() #判断路径是否为文件
- os.path.isdir(path) #判断路径是否为目录
- os.path.getsize()#返回文件大小,如果文件不存在就返回错误
- os.path.isabs() #判断是否为绝对路径
os.path中的一些实用函数汇总
最新推荐文章于 2022-09-06 14:04:58 发布