随笔分类 -  python学习

摘要:assert 断言 def div(num1, num2): # 断言 assert isinstance(num1, int), "值类型错误" assert isinstance(num2, int), "值类型错误" assert num2 != 0, "除数不为0" return num1 阅读全文
posted @ 2019-12-23 22:57 阿里云的奥斯卡 阅读(279) 评论(0) 推荐(0)
摘要:WTF表单 wtf.py pip install flask-wtf # 安装 from flask_wtf import FlaskForm from wtform import StringField, PasswordField, SubmmitField app.config["SECRET 阅读全文
posted @ 2019-12-19 22:54 阿里云的奥斯卡 阅读(326) 评论(0) 推荐(0)
摘要:jinjia2 模板 python实现 flask 内置语言 参照Djago实现 设置模板文件夹 设置模板语言 jinja2 demo6_template.html > 从代码渲染值 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF 阅读全文
posted @ 2019-12-18 22:12 阿里云的奥斯卡 阅读(258) 评论(0) 推荐(0)
摘要:钩子函数和装饰器路由实现 before_request 每次请求都会触发 before_first_requrest 第一次请求前触发 after_request 请求后触发 并返回参数 teardown_request 失败后触发 并返回异常 需要传入参数接收 from flask import 阅读全文
posted @ 2019-12-17 20:59 阿里云的奥斯卡 阅读(300) 评论(0) 推荐(0)
摘要:3.1正则转换器定义 Class RegexConverter(BaseConverter): regex = "[0-9]{6}" app.url_map.converters["re"] = RegexConverter @app.route("/user/<re:user_id>") def 阅读全文
posted @ 2019-12-17 00:45 阿里云的奥斯卡 阅读(170) 评论(0) 推荐(0)
摘要:路由参数与请求方式制定 ALT+回车 pycharm 快速导包 demo3 指定访问地址 与请求方式 # 给路由传入参数 使用尖括号 ,视图函数需要接收参数 @app.route("/index/<int:user_id>", method=['POST, 'GET']) def index(use 阅读全文
posted @ 2019-12-16 07:44 阿里云的奥斯卡 阅读(256) 评论(0) 推荐(0)
摘要:python Flask学习 阅读全文
posted @ 2019-12-15 13:15 阿里云的奥斯卡 阅读(226) 评论(0) 推荐(0)