Rumah > Artikel > pembangunan bahagian belakang > 解析python中executemany和序列用法教程
这篇文章主要介绍了详解python中executemany和序列的使用方法的相关资料,需要的朋友可以参考下
详解python中executemany和序列的使用方法
一 代码
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")
二 运行结果
y ======== ('Jim', 'Green') ('Hu', 'jie') I just deleted 2 rows
Atas ialah kandungan terperinci 解析python中executemany和序列用法教程. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!