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

问题描述

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

路径

模块 x
文件夹 x/y/z

错误代码

import x
t = x.y.z()

解决方案

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

你可能感兴趣的:(python)