python连接数据库出错
import pymysql con=pymysql.connect(host='127.0.0.1',user='root',passwd='1997520', port=3306,db='test1') cur=con.cursor() list=[("52192325124","liujihong","124")] cur.execute('insert into student(Uid,Uname,Upassword) values(%s,%s,%s)',list) con.commit() # cur.execute('select * from student') # res=cur.fetchall() # for row in res: # print(row[0]) cur.close() con.close() 报错如下: Traceback (most recent call last): File "D:/Python/workspace/Pysql/Mysql.py", line 8, in <module> cur.execute('insert into student(Uid,Uname,Upassword) values(%s,%s,%s)',list) File "D:\Python\workspace\Pysql\venv\lib\site-packages\pymysql\cursors.py", line 168, in execute query = self.mogrify(query, args) File "D:\Python\workspace\Pysql\venv\lib\site-packages\pymysql\cursors.py", line 147, in mogrify query = query % self._escape_args(args, conn)TypeError: not enough arguments for format string
慕数据8021029
安浪创想
相关分类