python怎么将列表保存到mysql
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)
])
版权声明
本文仅代表作者观点,不代表米安网络立场。
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。