美文网首页
Flask-web实现Python小问题汇总

Flask-web实现Python小问题汇总

作者: 冰西瓜大郎 | 来源:发表于2017-09-21 23:45 被阅读0次

1.python3中无unicode,已经变成str

<Response streamed [405 METHOD NOT ALLOWED]> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>405 Method Not Allowed</title>
<h1>Method Not Allowed</h1>
<p>The method is not allowed for the requested URL.</p>
本地测试Flask项目程序的时候遇到的,原因有可能是你的此条route('url')少了第二个参数,或者比如你使用post方式获取,但是并没有声明post
  File "/Users/lovehxy/.virtualenvs/flask/lib/python3.4/site-packages/wtforms/fields/core.py", line 175, in validate
    stop_validation = self._run_validation_chain(form, chain)
  File "/Users/lovehxy/.virtualenvs/flask/lib/python3.4/site-packages/wtforms/fields/core.py", line 195, in _run_validation_chain
    validator(form, self)
TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given

原因是:DataRequired需要加上()
email = StringField('email',validators=[DataRequired()])

相关文章

网友评论

      本文标题:Flask-web实现Python小问题汇总

      本文链接:https://www.haomeiwen.com/subject/oxonsxtx.html