● 奇怪展开
def __init__(self):
# 获取setting主机名 端口号和数据库名
self.host = settings[‘mysql_HOST‘]
self.port = settings[‘MySQL_PORT‘]
self.dbname = settings[‘MySQL_DBNAME‘]
self.conn = MySQLdb.connect(host=‘localhost‘, port=3306, db=‘douban‘, user=‘root‘, passwd=‘root‘,charset=‘utf8‘)
self.cur = self.conn.cursor()