文章内容
2019/11/11 10:11:46,作 者: 黄兵
AttributeError: __enter__
今天在运行with循环的时候,出现了如下错误:
AttributeError: __enter__
出现问题的原因:
代码书写错误,具体错误代码实例:
@staticmethod
def scan_no_build_count():
with(ConnConfig().Conn_MySQL()) as conn_mysql:
with closing(conn_mysql.cursor()) as cur:解决方案:
修改代码,修改内容如下:
@staticmethod
def scan_no_build_count():
with closing(ConnConfig().Conn_MySQL()) as conn_mysql:
with closing(conn_mysql.cursor()) as cur:黄兵个人博客原创。
评论列表