如何解决使用 os.scandir() 在 pycharm 中导致“未解析的属性引用”警告
我在 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 可能有问题,但不确定...感谢您对此事的任何帮助或详细说明,谢谢!
解决方法
看起来这是pycharm的一个错误。到时候暂时忽略。谢谢史蒂夫!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。