信息发布→ 登录 注册 退出

Python 3.12中`__int__`导致属性不可用:为什么我的GetConfig对象没有'conf'属性?

发布时间:2024-11-17

点击量:

python 3.12中`__int__`导致属性不可用:为什么我的getconfig对象没有'conf'属性?

python 3.12 中 init 中的属性不可用

在 python 3.12 中编写了一个程序,但是运行时遇到了一个错误,提示“attributeerror:getconfig 对象没有属性 conf”。

错误代码如下:

class getconfig(object):
    def __int__(self):
        # 创建一个属性
        self.conf = configparser.configparser()

    def get_db_host(self):
        return self.conf.get("db", "host")

if __name__ == "__main__":
    gc1 = getconfig()
    var = gc1.get_db_host()
标签:
在线客服
服务热线

服务热线

13331157271

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

微信号:

(点击微信号复制,添加好友)

打开微信

微信号已复制,请打开微信添加咨询详情!