詳解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") 二 運行結(jié)果
y ========('Jim', 'Green')('Hu', 'jie')I just deleted 2 rows以上就是python中executemany和序列的應(yīng)用,如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答
圖片精選