在python中,什么是字符缓冲区?

我是初学sqlite用户,遇到了一些麻烦,希望能找到可以提供帮助的人.

我试图从数据库中读取一些数据,将其放入python中的变量并将其打印到HTML页面上.

数据库中的表是calle“Status”,它包含两列“stamp”和“messages”. “stamp是包含时间戳的INT,”messages“包含TEXT.

@cherrypy.expose
def comment(self, ID = None):
    con = lite.connect('static/database/Status.db')
    output = ""
    with con:    
        cur = con.cursor()    
        cur.execute("SELECT * FROM Status WHERE stamp = ?", (ID,))
        temp = cur.fetchone()
        output = temp[0]

    comments = self.readComments(ID)


    page = get_file(staticfolder+"/html/commentPage.html")
    page = page.replace("$Status", output)

我得到的错误是:

Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/cherrypy/_cprequest.py", line 606, in respond
    cherrypy.response.body = self.handler()
  File "/usr/lib/pymodules/python2.7/cherrypy/_cpdispatch.py", line 25, in __call__
    return self.callable(*self.args, **self.kwargs)
  File "proj1base.py", line 184, in comment
    page = page.replace("$Status", output)
TypeError: expected a character buffer object

我想知道是否有人可以帮助我澄清字符缓冲区对象是什么,以及如何使用一个以使我的代码工作?

解决方法:

将“字符缓冲区”替换为“字符串”作为初学者. (有更多类型在Python中暴露“缓冲协议”,但现在不要理会它们.)最有可能的是,输出最终不是字符串.在错误发生之前将其类型记录在行中.

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能