Latest web development tutorials

Python os.readlink () method

Python File (File) method Python OS file / directory methods


Outline

os.readlink () method is used to return the soft link points to a file. Absolute fire may return a relative path.

Effective on Unix

grammar

readlink () method syntax is as follows:

os.readlink(path)

parameter

  • path - the path to find the soft link

return value

Returns the soft link points to a file

Examples

The following example demonstrates readlink () method of use:

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os

src = '/usr/bin/python'
dst = '/tmp/python'

# 创建软链接
os.symlink(src, dst)

# 使用软链接显示源链接
path = os.readlink( dst )
print path

The above program output is:

/usr/bin/python

Python File (File) method Python OS file / directory methods