擅长:python、mysql、java
<p>您可以在flask中使用变量,方法是在URL中写入这样从HTML传递的变量。
我是说</p>
<pre><code>from flask import Flask, render_template
app = Flask(__name__)
@app.route("/index")
def index():
a=3
b=4
c=a+b
return render_template('index.html',c=c)
@app.route("<variable1>/dif/<variable2>")
def dif(variable1,variable2):
d=c+a
return render_template('dif.html',d=d)
if __name__ == "__main__":
</code></pre>
<p>您的html将如下所示:
形式:</p>
<pre><code><form action="/{{ variable1 }}/index/{{ variable2}}" accept-charset="utf-8" class="simform" method="POST"
</code></pre>
<p>作为参考:</p>
<pre><code><a href="{{ url_for('index',variable1="variable1",variable2="variable2") }}"><span></span> link</a></li>
</code></pre>