我认为您必须将
mydb.commit()所有内容插入。
像这样
import csvimport MySQLdbmydb = MySQLdb.connect(host='localhost', user='root', passwd='', db='mydb')cursor = mydb.cursor()csv_data = csv.reader(file('students.csv'))for row in csv_data: cursor.execute('INSERT INTO testcsv(names, classes, mark )' 'VALUES("%s", "%s", "%s")',row)#close the connection to the database.mydb.commit()cursor.close()print "Done"


