在这里编程新手.每当我尝试在Python IDLE中"导入pprint"时,我都会收到以下错误:
>>> import pprint
Traceback (most recent call last):
File "<pyshell#21>", line 1, in <module>
import pprint
File "C:\Python34\pprint.py", line 10, in <module>
pprint(count)
NameError: name 'pprint' is not defined
Run Code Online (Sandbox Code Playgroud)
以为我会尝试在命令行中"pip install pprint",但这也不起作用:
PS C:\Python34> pip install pprint
Collecting pprint
Could not find a version that satisfies the requirement pprint (from versions: )
No matching distribution found for pprint
Run Code Online (Sandbox Code Playgroud)
我认为Python 3.4.3应该带有pprint模块.我如何让它工作?似乎无法导入pprint,但所有其他模块都工作正常.我需要pprint模块来完成Automate The Boring Stuff with Python的一些练习.谢谢你看我的问题.
我正在尝试创建一个将表单输入保存为URL查询的表单.但是,当我按下表单的提交按钮时,我不知道为什么会发生这种情况.我确定它与redirect()或我的表单有关.
site.py
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/')
def index():
return render_template("about.html")
@app.route('/hobbies/')
def blog():
return render_template("hobbies.html")
@app.route('/about/')
def about():
return render_template("about.html")
@app.route('/projects/', methods=['GET', 'POST'])
def projects():
return render_template("projects.html")
@app.route('/dress')
def dress():
return render_template("dress.html")
@app.route('/dress', methods=['GET', 'POST'])
def my_form_post():
min_bust = request.form['min_bust']
max_bust = request.form['max_bust']
min_waist = request.form['min_waist']
max_waist = request.form['max_waist']
min_length = request.form['min_length']
max_length = request.form['max_length']
return redirect(url_for('/dress/',
min_bust=min_bust,
max_bust=max_bust,
min_waist=min_waist,
max_waist=max_waist,
min_length=min_length,
max_length=max_length), code=302)
@app.route('/base/')
def base():
return render_template("base.html")
@app.errorhandler(404)
def page_not_found(e):
return render_template("404.html"), …Run Code Online (Sandbox Code Playgroud)