Flask013_ if 判断语句
- 调用
1 @app.route('/if') 2 def if_statement(): 3 age = 18 4 return render_template('if.html', age=age)
- if.html
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>if 语句</title> 6 </head> 7 <body> 8 {% if age >18 %} 9 <div>您已成年!</div> 10 {% elif age < 18 %} 11 <div>您为成年!</div> 12 {% else %} 13 <div>您刚成年!</div> 14 {% endif %} 15 </body> 16 </html>
- 效果