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://codercto.com/courses/l/10.html

查看所有标签

Learning PHP, MySQL, JavaScript, and CSS

Learning PHP, MySQL, JavaScript, and CSS

Robin Nixon / O'Reilly Media / 2012-9-3 / USD 39.99

If you're familiar with HTML, you can quickly learn how to build interactive, data-driven websites with the powerful combination of PHP, MySQL, and JavaScript - the top technologies for creating moder......一起来看看 《Learning PHP, MySQL, JavaScript, and CSS》 这本书的介绍吧!

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具