我是python的新手,正在编写在python中编写bash ls命令,我被困在ls -a选项中(根据联机帮助页):
Include directory entries whose names begin with a dot (`.’)
我知道os.listdir()但它没有列出特殊条目’.’和’..’
From the docs: os.listdir(path):
Return a list containing the names of the entries in the directory given by path. The list is in arbitrary order. It does not include the special entries ‘.’ and ‘..’ even if they are present in the directory.
我需要帮助通过python列出这些特殊条目,如果有人可以帮助我一点点,我将不胜感激.
谢谢你的耐心等待.
解决方法:
只需将它们手动添加到os.listdir()结果中即可. result = [os.curdir,os.pardir] os.listdir(path).
大多数现代文件系统不再创建实际的硬链接,但所有API都明确包含名称.
原文地址:https://codeday.me/bug/20190517/1120833.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。