1. 首页
  2. 数据库
  3. 其它
  4. python flask中动态URL规则详解

python flask中动态URL规则详解

上传者: 2021-01-04 00:13:11上传 PDF文件 38KB 热度 25次
URL是可以添加变量部分的, 把类似的部分抽象出来, 比如: @app.route('/example/1/') @app.route('/example/2/') @app.route('/example/3/') def example(id): return 'example:{ }'.format(id) 可以抽象为: @app.route('/example//') def wxample(id): return 'example:{ }'.format(id) 尖括号中的内容是动态的,id作为参数获得, 此时默认id为字符串类型 我们可以指定参数类型, 比如: st
下载地址
用户评论