main.py 文件源码

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

项目:dumb-pypi 作者: chriskuehl 项目源码 文件源码
def atomic_write(path):
    tmp = tempfile.mktemp(
        prefix='.' + os.path.basename(path),
        dir=os.path.dirname(path),
    )
    try:
        with open(tmp, 'w') as f:
            yield f
    except BaseException:
        os.remove(tmp)
        raise
    else:
        os.rename(tmp, path)


# TODO: at some point there will be so many options we'll want to make a config
# object or similar instead of adding more arguments here
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号