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
Published on 26-Dec-2017 10:01:27
Advertisements