27 lines
1.0 KiB
Markdown
27 lines
1.0 KiB
Markdown
---
|
||
title: "Python 的 os 和 os.path"
|
||
date: 2019-10-30T17:45:33+08:00
|
||
lastmod: 2019-10-30T17:45:33+08:00
|
||
tags: ["python", "os", "os.path"]
|
||
categories: ["python"]
|
||
---
|
||
|
||
- os.getcwd() #返回运行脚本的目录
|
||
- os.listdir() #获取目录中的内容
|
||
- os.path.basename() #去掉目录路径,返回文件名
|
||
- os.path.dirname() #去掉文件名,返回目录路径
|
||
- os.path.join() #组合成合法路径
|
||
- os.path.split() #返回路径和文件名元组
|
||
- os.path.splitdrive() #返回驱动器符号和路径元组
|
||
- os.path.splitext() #返回文件名和扩展名元组
|
||
- os.path.getatime() #返回文件最近的访问时间戳
|
||
- os.path.getctime() #返回文件的创建时间戳
|
||
- os.path.getmtime() #返回文件修改时间
|
||
- os.path.getsize() #返回文件大小(Bytes)
|
||
- os.path.exists() #指定目录或文件是否存在
|
||
- os.path.isabs() #指定路径是否为绝对路径
|
||
- os.path.isdir() #指定路径是否为目录
|
||
- os.path.isfile() #指定路径是否为文件
|
||
- os.path.samefile() #指定路径名是否指向同一个文件
|
||
|