schemer校验器的简单应用
2024-10-20 06:42:32
from schemer import Schema def func(account, password):
request_params = {
'account': account,
'password': password,
'name': '卢'
} param_schema = Schema({
'account': {'type': basestring, 'required': True},
'password': {'type': basestring, 'required': True},
}, strict=False) # strict=False 可以允许多传递参数 param_schema.validate(request_params) # 检测不通过直接抛异常
param_schema.apply_defaults(request_params) # attach 默认值 if __name__ == '__main__':
func('111','222')
最新文章
- php throw new Excpetion()之后,程序还往下继续运行吗?
- MemoryStream类
- python实现tailf
- 浅谈程序员创业(要有一个自己的网站,最好的方式还是自己定位一个产品,用心把这个产品做好。或者满足不同需求的用户,要有特色)good
- 关于java.sql.SQLRecoverableException: Closed Connection异常的解决方案(转)
- iOS获取网络时间与转换格式
- TRIZ系列-创新原理-32-改变颜色原理
- JAVA List<;T>; 如何初始化
- Shiro 加密helloWorld
- Scala编程入门---面向对象编程之Trait高级知识
- c++字节对齐
- web.xml中三种通配符及匹配规则
- Mysql分组查询group by语句详解
- TensorFlow学习入门
- InnoDB Next-Key Lock
- 【three.js练习程序】创建简单物理场景
- bitnami下webmin安装
- Ubuntu中Samba的安装配置和使用
- 如何在 block 中修改外部变量
- Information:java: Errors occurred while compiling module &#39;spring&#39;