January 2019
Beginner
318 pages
8h 23m
English
In the previous section, we learned how we can use shutil.move() to move files from source to destination. Using shutil.move(), files can be renamed. Create a shutil_rename_example.py script and write the following content in it:
import shutilshutil.move('hello.py', 'hello_renamed.py')
Run the script as follows:
$ python3 shutil_rename_example.py
Output:
Now, check that your filename will be renamed hello_renamed.py.
Read now
Unlock full access