Flask Sqlalchemy中文模糊搜索错误。

我数据库用的是sqlite, 模糊搜索中文的时候出现 ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings 请问怎么解决啊。 @main.route('/search')

def search():

`books = Book.query.filter(Book.name.like('%非洲%'))`

`return render_template('search.html', books=books)`
image
5 comments