python使用db实现将列表保存到mysql中
具体方法以下:
importMySQLdbdb=MySQLdb.connect(passwd="moonpie",db="thangs")
c=db.cursor()
c.executemany(
"""INSERTINTObreakfast(name,spam,eggs,sausage,price)
VALUES(%s,%s,%s,%s,%s)""",
[
("SpamandSausageLover'sPlate",5,1,8,7.95),
("NotSoMuchSpamPlate",3,2,0,3.95),
("Don'tWanyANYSPAM!Plate",0,4,3,5.95)
])
本文来源:https://www.yuntue.com/post/58913.html | 云服务器网,转载请注明出处!

微信扫一扫打赏
支付宝扫一扫打赏