flask过滤器filter是不是只作用在字符串上
来源:3-1 模板语法之模板标签(上)
麦兜搞_IT
2023-04-17 12:06:27
# 在app.py中 @app.route('/index') def use_filter(): str = 'hellopython' lists = [5,6,7,3,4,2,1] return render_template('index.html', lists=lists, str=str) # 在模版中使用filter过滤器报错 {% filter sort %} {{ lists }} {% endfilter %} # 在模版中使用管道式过滤器则正常显示 {{ lists|sort }}
# 使用filter过滤器报错
1回答
好帮手慕小猿
2023-04-17
同学,你好!是没有{%filter sort%} 这种写法,是字符串类型的数据也报错
祝学习愉快~
相似问题