python之os库
来源:互联网 发布:剑网三dbm数据那个好 编辑:程序博客网 时间:2024/05/01 12:58
1.常用属性与方法
2.一个例子
假如在/home/wpp下有一个test_os.py的文件,其内容如下
#!/usr/bin/env pythonimport os print os.name#posixprint os.getcwd()#/home/wppprint os.listdir(os.getcwd())#结果太长,在此就不给出了print os.path.split(os.getcwd())#('/home','wpp') #值得注意的是此方法只是简单的对路径进行了分割#并没有保证第二个元素一定是文件,如wppprint os.path.isfile(os.getcwd())#Falseprint os.path.isdir(os.getcwd())#Trueprint os.path.exists(os.getcwd())#Trueprint os.path.abspath('test_os.py')#/home/wpp/test_os.pyprint os.path.normpath(os.getcwd())#/home/wppprint os.path.getsize('test_os.py')#508print os.path.splitext('test_os.py')#('test_os','.py')print os.path.join(os.getcwd(),'test.sh')#/home/wpp/test.shprint os.path.basename('/home/wpp/test_os.py')#test_os.pyprint os.path.dirname('/home/wpp/test_os.py')#/home/wpp
0 0
- python之os库
- Python之os库
- python之os库
- python库之os+os.path
- Python学习之OS库
- Python 库之 os 源码
- python 标准库之os
- Python标准库之os模块
- 一天学习一个python库之os
- Python标准库学习之os.path
- PYTHON模块之os
- python之os类库
- python 之 os
- python之os模块
- python之os
- Python 模块之os
- Python模块之os
- Python 之os模块
- Java中的反射机制 一个利用反射进行对象拷贝的例子
- More Effective C++ ——019_理解临时对象的来源
- 20150924
- linux 查看网卡流量六种方法
- centos7为yum添加源
- python之os库
- 关于Eclipse配置的一些链接
- poj 2398 Toy Storage
- UI - Delegate模式
- Java的四种引用,强弱软虚,用到的场景
- easyui表单验证easyui-validatebox
- 读书笔记:MySQL数据库 数据类型优化二 用整形Int 存储 IP地址
- 一个另类的排序——睡排序
- 判断一个数的二进制有多少个1