Python模块学习——os
来源:互联网 发布:知阅小说网_原创小说网 编辑:程序博客网 时间:2024/06/05 20:18
os.sep 可以取代操作系统特定的路径分割符。
os.name字符串指示你正在使用的平台。比如对于Windows,它是'nt',而对于Linux/Unix用户,它是'posix'。
os.getcwd()函数得到当前工作目录,即当前Python脚本工作的目录路径。
os.getenv()和os.putenv()函数分别用来读取和设置环境变量。
os.listdir()返回指定目录下的所有文件和目录名。
os.curdir:返回当前目录('.')
os.remove()函数用来删除一个文件。
os.system()函数用来运行shell命令。
os.chdir(dirname):改变工作目录到dirname
os.linesep字符串给出当前平台使用的行终止符。例如,Windows使用'\r\n',Linux使用'\n'而Mac使用'\r'。
os.path.isdir(name):判断name是不是一个目录,name不是目录就返回false
os.path.isfile(name):判断name是不是一个文件,不存在name也返回false
os.path.exists(name):判断是否存在文件或目录name
os.path.getsize(name):获得文件大小,如果name是目录返回0L
os.path.abspath(name):获得绝对路径
os.path.normpath(path):规范path字符串形式
os.path.split(name):分割文件名与目录(事实上,如果你完全使用目录,它也会将最后一个目录作为文件名而分离,同时它不会判断文件或目录是否存在)
os.path.splitext():分离文件名与扩展名
os.path.join(path,name):连接目录与文件名或目录
os.path.basename(path):返回文件名
os.path.dirname(path):返回文件路径
以上就是Python os模块的一些比较重要的内容。
- python模块学习——os
- Python模块学习——os
- Python OS模块学习
- python-os模块学习
- python os模块学习
- python os模块学习
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python模块学习-os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- Python 模块学习:os模块
- 训练4 习题4
- SO_REUSEPORT使用示例
- Mysql中那些锁机制之InnoDB
- HDU 2255 KM模版题
- sed部分用法备忘
- Python模块学习——os
- Hadoop 通用数据摄取框架 Gobblin
- CentOS 7.x NAT模式上网配置
- spring-ioc
- MySQL5.5主从配置
- 手把手教你如何把java代码,打包成jar文件以及转换为exe可执行文件
- Dom4J生成xml和包含CDATA问题
- Python模块学习——re
- tensorflow从0开始(6)——保存加载模型