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
WebWork in Action
Jason Carreira、Patrick Lightbody / Manning / 01 September, 2005 / $44.95
WebWork helps developers build well-designed applications quickly by creating re-usable, modular, web-based applications. "WebWork in Action" is the first book to focus entirely on WebWork. Like a tru......一起来看看 《WebWork in Action》 这本书的介绍吧!