in_place.py 文件源码

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

项目:inplace 作者: jwodder 项目源码 文件源码
def force_rename(oldpath, newpath):
    """
    Move the file at ``oldpath`` to ``newpath``, deleting ``newpath``
    beforehand if necessary
    """
    if hasattr(os, 'replace'):  # Python 3.3+
        os.replace(oldpath, newpath)
    else:
        if sys.platform.startswith('win'):
            try_unlink(newpath)
        os.rename(oldpath, newpath)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号