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)
评论列表
文章目录