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

查看所有标签

Squid: The Definitive Guide

Squid: The Definitive Guide

Duane Wessels / O'Reilly Media / 2004 / $44.95 US, $65.95 CA, £31.95 UK

Squid is the most popular Web caching software in use today, and it works on a variety of platforms including Linux, FreeBSD, and Windows. Squid improves network performance by reducing the amount of......一起来看看 《Squid: The Definitive Guide》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具