Python3 os.readlink() 方法

Python 3 教程 · 2019-02-07 17:56:30

概述

os.readlink() 方法用于返回软链接所指向的文件,可能返回绝对或相对路径。

在Unix中有效

语法

readlink()方法语法格式如下:

os.readlink(path)

参数

  • path -- 要查找的软链接路径

返回值

返回软链接所指向的文件

实例

以下实例演示了 readlink() 方法的使用:

#!/usr/bin/python3

import os

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

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

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

执行以上程序输出结果为:

/usr/bin/python

点击查看所有 Python 3 教程 文章: https://www.codercto.com/courses/l/10.html

查看所有标签

A Byte of Python

A Byte of Python

Swaroop C H / Lulu Marketplace / 2008-10-1 / USD 27.98

'A Byte of Python' is a book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. If all you know about computers is how to save t......一起来看看 《A Byte of Python》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试