pycharm报错是为什么?
这是涉及的代码,跟着一步一步打的 应该没错
from flask import Flask,session,render_template,redirect,Blueprint,request
from utils.errorResponse import *
import time
from utils.query import query
from snownlp import SnowNLP
ub = Blueprint('user',__name__,url_prefix='/user',template_folder='templates')
@ub.route('/login')
def login():
if request.method == 'GET':
return render_template('login.html')
@ub.route('/register',methods=['GET','POST'])
def register():
if request.method == 'POST':
request.form = dict(request.form)
if request.form['password'] != request.form['passwordCheked']:
return '两次密码不符'
else:
def filter_fn(item):
return request.form['username'] in item
users = query('select * from user', [], 'select')
filter_list = list(filter(filter_fn, users))
if len(filter_list):
return errorResponse('该用户名已被注册')
else:
time_tuple = time.localtime(time.time())
query('insert into user(username,password,createTime) values(%s,%s,%s)',
[request.form['username'], request.form['password'],
str(time_tuple[0]) + '-' + str(time_tuple[1]) + '-' + str(time_tuple[2])])
return redirect('/user/login', 301)
else:
return render_template('register.html')
from flask import render_template
def errorResponse(errorMsg):
return render_template('error.html',errorMsg=errorMsg)
from pymysql import *
conn = connect(host='localhost',user='root',password='root',database='weiboarticles',port=3306)
cursor = conn.cursor()
def query(sql,params,type='no_select'):
params = tuple(params)
cursor.execute(sql,params)
conn.ping(reconnect=True)
if type != 'no_select':
data_list = cursor.fetchall()
conn.commit()
return data_list
else:
conn.commit()
return '数据库语句执行成功'
这是报错的信息