This commit is contained in:
2021-11-14 14:32:08 +08:00
parent f75ad8bedd
commit b0f6120151
152 changed files with 22219 additions and 8 deletions

26
content/post/python-os.md Normal file
View File

@@ -0,0 +1,26 @@
---
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() #指定路径名是否指向同一个文件