Python os.symlink() Method
Python OS File/Directory Methods
Overview
os.symlink() method is used to create a symbolic link.
A symbolic link is a special type of file that contains a reference to another file or directory and can point to different locations in the file system.
Syntax
symlink()The method syntax is as follows:
os.symlink(src, dst)
Parameters
src-- Path of the target file or directory for which the symbolic link is to be created.
dst-- Path and name of the symbolic link.
Return Value
This method has no return value.
Example
The following example demonstrates the use of the symlink() method:
Example
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
src = '/usr/bin/python'
dst = '/tmp/python'
# Create a soft link
os.symlink(src, dst)
print "Soft link created successfully"
The output of executing the above program is:
Symbolic link created successfullyOther Extensions