The Python method os.symlink() is used to create a symbolic link in the file system. The symlink is also known as soft link. It serves as a reference or pointer to another file or directory.
SyntaxFollowing is the syntax for os.symlink() method −
os.symlink(src, dest)Parameters
The Python os.symlink() method accept two parameters, which are as follows −
src − This parameter specifies the path of the source file.
dest − It specifies the path where the symbolic link should be created.
The Python os.symlink() method does not return any value.
ExampleIn the following example, we are creating a symbolic link using the symlink() method.
import os src = "/home/tp/Python/Tutorials/tmpfile" dst = "/home/tp/Python/tmpdir" # This creates a symbolic link os.symlink(src, dst) print ("symlink created")
On running the above program, it will create a symbolic link in /tmpdir directory.
symlink created
python_files_io.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4