加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python-2.7 – scandir上的ImportError

发布时间:2020-12-20 13:14:17 所属栏目:Python 来源:网络整理
导读:我试图使用 scandir package作为python 2.7中os.walk的替代品.但是,在导入期间,将引发ImportError,如下所示. Python 2.7.12 (default,Jul 1 2016,15:12:24) [GCC 5.4.0 20160609] on linux2Type "help","copyright","credits" or "license" for more informa
我试图使用 scandir package作为python 2.7中os.walk的替代品.但是,在导入期间,将引发ImportError,如下所示.

Python 2.7.12 (default,Jul  1 2016,15:12:24) 
[GCC 5.4.0 20160609] on linux2
Type "help","copyright","credits" or "license" for more information.

>>> from scandir import scandir,walk
Traceback (most recent call last):
  File "<stdin>",line 1,in <module>
  File "scandir.py",line 2,in <module>
    from scandir import walk
ImportError: cannot import name walk

在广泛搜索并且在这一点上非常难倒之后,我无法找到任何对此错误的引用(除了循环导入之外).任何帮助深表感谢 !

解决方法

您在当前工作目录中有一个名为scandir.py的文件.

重命名它,让sys.path中的scandir发挥其魔力.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读