关于python静态方法模块外访问报'module' object has no attribute
| Log.py
| __init__.py
Exception
| ...
CmdOps
| SpecCmdOps.py
| __init__.py
——————————————————————————————————
Log.py 部分实现
class Log:
LOGER_NAME = "zyxd"
__instance = None
@staticmethod
def init(logconf):
logging.config.fileConfig(logconf);
Log.__instance = logging.getLogger(Log.LOGER_NAME)
Log.__instance.info(u"初始化成功")
@staticmethod
def i(msg):
if Log.__instance:
Log.__instance.info(msg)
Log.py所在__init__.py内容如下
from Log import Log
——————————————————————————————————
SpecCmdOps.py 所在目录__init__.py内容如下
from SpecCmdOps import SpecCmdOps
在SpecCmdOps.py
from ..Common import Log
class SpecCmdOps:
def somemethod(self):
Log.i(u"测试而已")
但是上面语句执行报错,'module' object has no attribute 'i'
在IDE里,是可以直接跳转到Log定义,打印Log内容如下
<module 'PyScript.Common.Log' from 'E:\my_work\PyScript\Common\Log.pyc'>
打印Log所有属性,的确没有看到相关i属性。
请大神指点迷津。。。。
相关推荐
webdriver不能启动浏览器,报module ‘selenium.webdriver’ has no attribute”问题解决办法
"webdriver不能启动浏览器,报module ‘selenium.webdriver’ has no attribute”问题的解决方案"在使用Python的Selenium库进行自动化测试
AttributeError: module ‘xxx‘ has no attribute
本文主要介绍了AttributeError: module ‘xxx’ has no attribute及其解决方案,希望能对新手有所帮助。 文章目录 1. 问题描述 2. 解决方案
python报错: list object has no attribute shape的解决
在遇到“list object has no attribute 'shape'”或“'list' object has no attribute 'astype'”这类错误时,需要检查数据类型是否正确
python报错: 'list' object has no attribute 'shape'的解决
在Python编程中,`'list' object has no attribute 'shape'`这个错误通常发生在尝试访问一个列表(list)对象的`shape`属性时,而`shape`是属于NumPy
python错误:AttributeError: ‘module’ object has no attribute ‘setdefaultencoding’问题的解决方法
在Python编程中,遇到"AttributeError: 'module' object has no attribute 'setdefaultencoding'"错误是由于对早期Python版本


