How to create hardlink of a file using Python?

PythonServer Side ProgrammingProgramming

The method, dst) creates a hard link pointing to src named dst. This method is very useful to create a copy of existing file.


For example, if you have a file called photo.jpg and want to create a  hard link to it called my_photo.jpg, then you could simply use:

>>> import os
>>>'photo.jpg', 'my_photo.jpg')

 Now if you list the files in that directory, you'll get the my_photo

Updated on 13-Dec-2019 09:54:33