format.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:treecat 作者: posterior 项目源码 文件源码
def pickle_dump(data, filename):
    """Serialize data to file using gzip compression."""
    if filename.endswith('.pkz'):
        with gzip.open(filename, 'wb') as f:
            pickle.dump(data, f, protocol=2)  # Try to support python 2.
    elif filename.endswith('.jz'):
        with gzip.open(filename, 'wt') as f:
            f.write(json_dumps(data))
    else:
        raise ValueError(
            'Cannot determine format: {}'.format(os.path.basename(filename)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号