”AttributeError: ‘module’ object has no attribute ‘xxx’”

妖狐艹你老母 2023-01-03 01:57 244阅读 0赞

问题描述

自定义python 模块x,在导入其文件夹下的y时,出现 以下问题”AttributeError: ‘module’ object has no attribute ‘xxx’”

路径

模块 x
文件夹 x/y/z

错误代码

  1. import x
  2. t = x.y.z()

解决方案

在模块x下的__init__.py文件写入 from . import y

发表评论

表情:
评论列表 (有 0 条评论,244人围观)

还没有评论,来说两句吧...

相关阅读