>>> list(Path('test').glob('*'))[PosixPath('test/.bar'), PosixPath('test/foo')]我想知道这是故意的还是可能的错误/疏忽.I'd like to know if this is intended or possibly a bug/oversight. glob模块文档指出以点开头的文件是特殊情况:The glob module documentation states that files starting with a dot are special cased: glob将以点(.)开头的文件名视为特殊情况 glob treats filenames beginning with a dot (.) as special cases表示要使用glob.glob('*')给出的结果.但是pathlib的glob呢?我在文档中找不到任何相关信息.这是预期的行为吗?两种功能都不应该产生相同的结果吗?Meaning that the result given by glob.glob('*') is intended. But what about pathlib's glob? I couldn't find any relevant information in the docs. Is this the intended behavior? Shouldn't both functions produce the same results?推荐答案根据 issue#26096 官方的错误跟踪器,这种区别被认为是not a bug,因此完全有意.As per issue #26096 on the official bug tracker, this difference has been deemed not a bug and is therefore completely intended.为查找找到 @vaultah . 这篇关于为什么glob.glob和pathlib.Path.glob对隐藏文件的处理方式不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-06 13:37