AttributeError: module 'pymysql' has no attribute 'connect'前一秒还能运行,然后就不行了
# 插入数据 import pymysql db = pymysql.connect('localhost', 'root', 'root', 'dada') cursor = db.cursor() sql = "insert into py_user (name) values('hello');" try: cursor.execute(sql) db.commit() print("插入成功") except: print("插入失败") db.rollback() cursor.close() db.close()