我是python的新手,现在尝试运行我的应用时遇到问题,但是我无法从调试器中找到此错误,如果有人可以告诉我如何解决, 问候
import json
from difflib import get_close_matches
from flask import Flask, render_template
from flask_bootstrap import Bootstrap
app = Flask(__name__)
Bootstrap(app)
collection = json.load(open("collection.json"))
@app.route('/')
def home():
return render_template('home.html')
@app.route('/nosotros')
def prueba():
return render_template('nosotros.html')
@app.route('/traductor')
def traductor(word):
if word in collection:
return collection[word]
elif len(get_close_matches(word, collection.keys())) > 0:
yn = input("Quizas estas buscando esta palabra %s ? Presiona S
para si o N para No:b" % get_close_matches(word, collection.keys())[0])
if yn == "S":
return collection[get_close_matches(word, collection.keys())[0]]
elif yn == "N":
return "Palabra no encontrada. Por favor busca de nuevo."
else:
return "No has escrito ninguna palabra"
print('\n***** Bienvenido al Diccionario KUNA *****\n')
word = input("Escribe tu palabra: ")
output = traductor(word)
if type(output) == list:
for item in output:
print(item)
else:
print(output)
return render_template('traductor.html')
if __name__ == '__main__':
app.run(debug=True)
第35行出现错误: 重新列出文件“ /home/jahirocoba/.local/lib/python3.7/site-packages/flask/_compat.py”,第35行 在此frameraise值中打开一个交互式python shell