python-pickle/cPickle/glob/tarfile
2016-07-22 19:44
465 查看
----------------------------pickle----------------------------
try: import cPickle as pickle
except: import pickle
dump/load
dumps/loads
a = dic/array/list
with open(file, 'wb') as f:
pickle.dump(a, f, -1)
with open(file) as f:
a = pickle.load(f)
--------------------------------glob-----------------
xx = glob.glob('xxx') [] * . return list
yy = glob.iglob('xxx') return generator
--------------------------tarfile------------------
import tarfile
tar = tarfile.open(file.tar)
tar.extractall()
tar.close()
with tarfile.open(file) as tar:
tar.extractall()
tar = tarfile.opem(file.tar, 'w')
tar.add(file)
-------------------------------refrence-------------------------------
https://docs.python.org/3/library/tarfile.html
try: import cPickle as pickle
except: import pickle
dump/load
dumps/loads
a = dic/array/list
with open(file, 'wb') as f:
pickle.dump(a, f, -1)
with open(file) as f:
a = pickle.load(f)
--------------------------------glob-----------------
xx = glob.glob('xxx') [] * . return list
yy = glob.iglob('xxx') return generator
--------------------------tarfile------------------
import tarfile
tar = tarfile.open(file.tar)
tar.extractall()
tar.close()
with tarfile.open(file) as tar:
tar.extractall()
tar = tarfile.opem(file.tar, 'w')
tar.add(file)
-------------------------------refrence-------------------------------
https://docs.python.org/3/library/tarfile.html
相关文章推荐
- 转载:python使用urllib2抓取防爬取链接
- Numpy 常用函数及读写操作
- Python 关于正负无穷float(‘inf’)的一些用法
- Python之urlparse模块
- python中ascii码和字符的转换
- 利用python如何刷访问量
- python 之编码转换 unicode, utf-8, utf-16, GBK
- python 多线程爬虫
- 记一次安装Ipython的流程
- Python sort系列
- python排序函数sort()、sorted()、argsort()
- 文本处理(python)
- Scrapy:Python的爬虫框架----原理介绍
- python——异常处理
- Python中向excel中写入数据
- python开发_platform_获取操作系统详细信息工具
- python 正则表达式 之re.findall
- Python 学习笔记三 操作PostgreSQL数据库
- 支持向量机1
- 习题14 提示和传递