【Python模块】os & linecache & hashlib & commands & sys & time & datetime
2016-09-05 16:07
1046 查看
python模块整理
一、os模块
【1】os.walk(dir_path) 遍历某路径下的所有文件
【2】os.path.join(path, name) 连接目录与文件名或目录
【3】os.path.exists(name)判断是否存在文件或目录name
【4】os.path.getsize(name) 获得文件大小
【5】参考链接
http://developer.51cto.com/art/201003/186045.htm
二、linecache模块
【1】linecache.getline(filename, lineno)获取文件的某一行的内容
【2】linecache.getlines(filename) 获取文件的全部内容,输出为列表格式
【3】参考链接
http://www.csdn123.com/html/topnews201408/98/9498.htm
三、hashlib模块
【1】MD5:hashlib.md5(data).hexdigest()
【2】SHA-1:hashlib.sha1(data).hexdigest()
【3】参考链接
http://www.cnblogs.com/the4king/archive/2012/02/06/2340660.html
四、commands模块
【1】commands.getoutput(command) 用于调用Linux shell命令,并返回状态和结果
【2】参考链接
http://blog.csdn.net/dbanote/article/details/9414133
五、subprocess模块
【1】subprocess.Popen(command, shell=True)用于调用Linux shell命令,并返回returncode属性和执行结果
【2】return_code如果为127,表示command not found,也就是上例apktool命令not found
【3】参考链接
http://blog.csdn.net/g457499940/article/details/17068277
六、sys模块
【1】sys.path动态改变Python的搜索路径,加入到PATH环境变量中
【2】参考链接
http://blog.csdn.net/l_b_yuan/article/details/52260646
七、time模块
【1】time.time()获取当前时间(时间戳的形式)
【2】参考链接
http://www.jianshu.com/p/da0ef08c9ea7
八、datetime模块
【1】datetime.datetime.now()获取当前时间
【2】参考链接
http://peiqiang.net/2014/08/15/python-time-and-datetime.html
一、os模块
【1】os.walk(dir_path) 遍历某路径下的所有文件
【2】os.path.join(path, name) 连接目录与文件名或目录
【3】os.path.exists(name)判断是否存在文件或目录name
【4】os.path.getsize(name) 获得文件大小
【5】参考链接
http://developer.51cto.com/art/201003/186045.htm
二、linecache模块
【1】linecache.getline(filename, lineno)获取文件的某一行的内容
【2】linecache.getlines(filename) 获取文件的全部内容,输出为列表格式
【3】参考链接
http://www.csdn123.com/html/topnews201408/98/9498.htm
三、hashlib模块
【1】MD5:hashlib.md5(data).hexdigest()
【2】SHA-1:hashlib.sha1(data).hexdigest()
【3】参考链接
http://www.cnblogs.com/the4king/archive/2012/02/06/2340660.html
四、commands模块
【1】commands.getoutput(command) 用于调用Linux shell命令,并返回状态和结果
【2】参考链接
http://blog.csdn.net/dbanote/article/details/9414133
五、subprocess模块
【1】subprocess.Popen(command, shell=True)用于调用Linux shell命令,并返回returncode属性和执行结果
【2】return_code如果为127,表示command not found,也就是上例apktool命令not found
【3】参考链接
http://blog.csdn.net/g457499940/article/details/17068277
六、sys模块
【1】sys.path动态改变Python的搜索路径,加入到PATH环境变量中
【2】参考链接
http://blog.csdn.net/l_b_yuan/article/details/52260646
七、time模块
【1】time.time()获取当前时间(时间戳的形式)
【2】参考链接
http://www.jianshu.com/p/da0ef08c9ea7
八、datetime模块
【1】datetime.datetime.now()获取当前时间
【2】参考链接
http://peiqiang.net/2014/08/15/python-time-and-datetime.html
相关文章推荐
- python入门----3+1个内置模块:sys,os, time,datetime
- Python time、datetime、os、random、sys、hashlib、json、shutil、logging、paramiko、subprocess、ConfigParser、xml、shelve模块的使用
- Python模块:time、datetime、random、os、sys
- Python sys&os模块
- Python模块 os commands sys
- Python常用模块-时间模块(time&datetime)
- Python内置模块之time、random、hashlib、OS、sys、UUID模块
- day6 模块time datetime random os sys json pikle
- python3之xml&ConfigParser&hashlib&Subprocess&logging模块
- Python常用模块-SYS、OS、Time、hashlib
- python模块: time & datetime
- 分享:Python2.7 linecache&&timeit模块学习
- Py修行路 python基础 (二十)模块 time模块,random模块,hashlib模块,OS及sys模块
- python sys,os,time模块的使用(包括时间格式的各种转换)
- python的基础模块(os,sys,time,shutil,differlib,socket)
- 【Python】随机模块random & 日期时间のtime&&datetime
- python常用模块(模块和包的解释,time模块,sys模块,random模块,os模块,json和pickle序列化模块)
- Python -> subprocess, os.system,commands,popend -> 模块对比
- Python3之时间模块time & datetime & calendar
- Python hashlib、hmac模块