pymysql链接:pymysql.err.InterfaceError: (0, ‘’)解决办法 db = pymysql.connect(host='127.0.0.1',port=3306,user='user', passwd='pwd', db='db_name', charset='utf8') sql = 'select * from table_name' #添加db.ping(reconnect=True) db.ping(reconnect=True) #检测链接是否正常,链接异常会重连 cur.execute(sql) db.commit()