博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
readlink函数_Python中的`readlink -m`等效函数以获取规范的文件名
阅读量:2515 次
发布时间:2019-05-11

本文共 1304 字,大约阅读时间需要 4 分钟。

readlink函数

readlink -m can get canonical file name by resolving every symlinks in every component of the given path recursively. In , the os.readlink() function does not do so. Any equivalent function in Python to the readlink -m line?

readlink -m可以通过递归解决给定路径的每个组件中的每个符号链接来获取规范的文件名。 在 , os.readlink()函数不这样做。 Python中与readlink -m 行等效的功能吗?

Specifically, it does:

具体来说,它可以:

canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence

通过递归跟随给定名称的每个组件中的每个符号链接来规范化,而无需组件的存在



does 2 things:

– canonicalize by following every symlink in every component of the given name recursively, and
– without requirements on components existence

做两件事:

–通过递归跟随给定名称的每个组件中的每个符号链接来规范化;
–无需组件存在

In Python, the equivalent function is `os.path.realpath()`.

在Python中,等效函数为`os.path.realpath()`

One example is as follows. Note that the directory `/tmp/w` does not exist at all.

一个例子如下。 注意,目录“ / tmp / w”根本不存在。

$ ls -lhalrwxrwxrwx  1 ericma ericma    6 Nov 25 00:00 w -> /tmp/w$ readlink -f ./w/tmp/w$ readlink -f ./w/x$ readlink -m ./w/x/tmp/w/x$ python3Python 3.6.8 (default, Oct  7 2019, 12:59:55) [GCC 8.3.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> import os>>> os.path.realpath("./w/x")'/tmp/w/x'

翻译自:

readlink函数

转载地址:http://qyowd.baihongyu.com/

你可能感兴趣的文章
ps -aux
查看>>
Uploadify 上传文件插件详解
查看>>
游戏开发设计模式之子类沙盒模式(unity3d 示例实现)
查看>>
时间复杂度与空间复杂度
查看>>
Ajax 是什么?Ajax 的交互模型?同步和异步的区别?如何解决跨域问题
查看>>
Session 起航 登录会话和注销请求 重定向和转发
查看>>
毕设问题小记——Struts2如何将父类属性序列化为JSON格式
查看>>
有效投标不足三家不应是重新招标的必要条件
查看>>
标准分页
查看>>
3dContactPointAnnotationTool开发日志(二四)
查看>>
C语言运算符优先级
查看>>
javascript 之this指针-11
查看>>
完成登录与注册页面的前端
查看>>
hihocoder 1643 Puzzle Game(北京icpc2017 现场赛)
查看>>
vim 简单理解三种模式 粗暴入门
查看>>
django模板层之静态文件引入优化
查看>>
转载使用命令wsimport构建WebService客户端
查看>>
java实现23种设计模式之模版方法模式
查看>>
小程序·云开发实战 - 校园约拍小程序
查看>>
闲话函数式变成与OOP
查看>>