我在pycharm中有以下python代码:
# search for files or folders with two or more adjacent spaces
def twoplusspaces(path):
srchr = os.scandir(path) # get our iterator
# iterate through folders and files looking for adjacent blank spaces
for entry in srchr:
if " " in entry.name:
print(entry.name) # print name of file/folder with 2+ spaces
if entry.is_dir():
twoplusspaces(path + "\\" + entry.name) # recursive call when folder encountered
srchr.close() # done using iterator
这工作正常,但pycharm警告我entry.name和entry.is_dir()的“未解析属性引用”。我觉得这很奇怪,因为Python文档说,scandir()返回的DirEntry对象存在这些属性:https://docs.python.org/3/library/os.html#os.DirEntry
看起来我的pycharm可能有问题,但不确定。。。在此问题上的任何帮助或详细说明都将不胜感激,谢谢
看起来这是一个有着迷人魅力的虫子。我们暂时不理会。谢谢史蒂夫
相关问题 更多 >
编程相关推荐