源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

详解python中executemany和序列的使用方法

  • 时间:2022-02-25 16:32 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:详解python中executemany和序列的使用方法
[b]详解python中executemany和序列的使用方法[/b] [b]一 代码[/b]
import sqlite3 
persons=[ 
  ("Jim","Green"), 
  ("Hu","jie") 
  ] 
conn=sqlite3.connect(":memory:") 
conn.execute("CREATE TABLE person(firstname,lastname)") 
conn.executemany("INSERT INTO person(firstname,lastname) VALUES(?,?)",persons) 
for row in conn.execute("SELECT firstname,lastname FROM person"): 
  print(row) 
   
print("I just deleted",conn.execute("DELETE FROM person").rowcount,"rows") 
[b] 二 运行结果[/b]
y ========
('Jim', 'Green')
('Hu', 'jie')
I just deleted 2 rows
以上就是python中executemany和序列的应用,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部