'How to copy files in Python without `os.rename` or `shutil`?

I have some photos and some videos that I have to copy them in another folder without using shutil and os.rename. I can’t use shutil and os.rename because this is a condition for that Python exercise. I tried open but it only worked for text and not photos and videos.



Solution 1:[1]

You can use pathlib:

from pathlib import Path

Path("old_file.png").write_bytes(Path("new_file.png").read_bytes())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 LeopardShark