【问题标题】:utf error on f.read()) in database script数据库脚本中 f.read()) 上的 utf 错误
【发布时间】:2016-04-09 06:44:24
【问题描述】:

我正在处理我的第一个更大的 python 烧瓶 web 项目,当我尝试编译时遇到这个错误: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio\2.2\visualstudio_py_debugger.py:497: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - 将它们解释为不平等 handlers = self.handler_cache.get(文件名) 出现此错误,并且由于我使用 Visual Studio 进行开发,因此我在此处获得断点:

def init_db():
with app.app_context():
    db = get_db()
    with app.open_resource('schema.sql',mode='r') as f:
        db.cursor().executescript(f.read()) //ERROR on last )
    db.commit()

因为我对 python 很陌生,一般来说,我试图寻找一个特定的答案,但找不到解决问题的答案。 我的进口是:

# -*- coding: utf-8 -*- 
   from datetime import datetime
   from FlaskWebProject2 import app
   import sqlite3
   from flask import Flask, request, g, redirect, url_for, abort, render_template, flash, jsonify

【问题讨论】:

    标签: python python-2.7 flask


    【解决方案1】:

    发现错误。

    是由于 sql 文件中的错误导致数据库脚本在初始化时崩溃

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-07-26
      • 2021-04-24
      • 1970-01-01
      • 1970-01-01
      • 2018-04-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多