Python os.symlink() method
Python OS file/directory methods
Overview
The os.symlink() method creates a symbolic link.
A symbolic link is a special file type that contains a reference to another file or directory and can point to different locations in the file system.
Syntax
The **symlink()** method syntax is as follows:
os.symlink(src, dst)
Parameters
-
src -- the path of the target file or directory for which to create the symbolic link.
-
dst -- the 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 symbolic link
os
.
symlink
(
src
,
dst
)
"
Symbolic link created successfully
"
The output of the above program is:
软链接创建成功