pathlib.Path.rename()

Path.rename(target)

Rename this file or directory to the given target. On Unix, if target exists and is a file, it will be replaced silently if the user has permission. target can be either a string or another path object:

>>> p = Path('foo')
>>> p.open('w').write('some text')
9
>>> target = Path('bar')
>>> p.rename(target)
>>> target.open().read()
'some text'
doc_python
2016-10-07 17:40:30
Comments
Leave a Comment

Please login to continue.