How to create softlink of a file using Python?

PythonServer Side ProgrammingProgramming

The method os.symlink(src, dst) creates a symbolic link dst pointing to src. For example, if you have a file called photo.jpg and want to create a softlink/symbolic link to it called my_photo.jpg, then you could simply use:

Example

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

Now if you list the files in that directory, you'll get the my_photo.jpg there as well.

raja
Updated on 13-Dec-2019 09:56:43

Advertisements