解析python中executemany和序列用法教程


本文摘自php中文网,作者巴扎黑,侵删。

这篇文章主要介绍了详解python中executemany和序列的使用方法的相关资料,需要的朋友可以参考下

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

一 代码


1

2

3

4

5

6

7

8

9

10

11

12

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")

二 运行结果


1

2

3

4

y ========

('Jim', 'Green')

('Hu', 'jie')

I just deleted 2 rows

以上就是解析python中executemany和序列用法教程的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python如何导入excel

Python析构函数与构造函数的用法讲解

Python中迭代器和列表解析怎么使用?

mac怎么使用Python

Python类中怎么定义方法

Python怎么查看logging

学会Python爬虫怎么赚钱

Python面向对象编程中类和实例的简单讲解(附示例)

Python中如何获取字符串的长度

Python如何查找字符串的长度?(代码示例)

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...