第1个回答 2017-10-24
with open("fileinfo.txt", "rt") as handle:
datas = [ln.split('\t') for ln in handle]
conn = MySQLdb.connect(host='localhost', user='mysql', passwd='', db='db')
curr = conn.cursor()
curr.executemany("insert into tb values (?, ?, ?)", datas)
conn.commit()本回答被提问者采纳