Python(PyCharm) Flask运行报错 TypeError: object of type 'int' has no len()
Flask运行报错 TypeError: object of type ‘int’ has no len()
- 报错描述
基于Python Flask实现一个普通的注册表单验证字段上传界面,如图
register.html
form.py
app.py
看着没什么问题,但运行起来就报错了
- 解决方法:
将IntegerField改为StringField 问题解决
- 解决描述
查看报错信息:TypeError: object of type ‘int’ has no len() 说明整型不具备判断长度的方法所以 出错,所以定位调用了Length方法的代码,发现只有这两个地方调用
而报错的是int 所以指向IntegerField,但由于检测的是电话号码这一属性,所以直接改成StringField就行,问题解决 ????