import sqlite3
import html1
conn = sqlite3.connect('路径\\Result.db3')
c = conn.cursor()
cursor = c.execute("SELECT ID, content from Content where id=73452")
for row in cursor:
#print ("did = ", row'sqlite3.Cursor' object has no attribute 'commit'[0])
#print(html1.content(row[1]))
morepic1=html1.getpicurl(row[1])
did=row[0]
print(morepic1,int(did))
#print("UPDATE Content set morepic ='{0}' where ID={1}".format(morepic1,did))
c.execute("UPDATE Content set morepic ='{0}' where ID={1}".format(morepic1,int(did)))
conn.commit()
conn.close()
少了conn.commit()
该博客展示了如何使用 Python 的 sqlite3 模块连接并查询 SQLite 数据库,从中获取特定 ID 的内容。接着,它调用了一个 html1 函数来处理查询结果中的 HTML 内容,并获取额外的图片 URL。最后,更新数据库中对应记录的 'morepic' 字段,保存更改并关闭连接。此博客涉及数据库操作和 HTML 解析技术。

2031

被折叠的 条评论
为什么被折叠?



