gpt4 book ai didi

python - 如何请求选择标签名称选择,而不是 flask 中的值选择?

转载 作者:行者123 更新时间:2023-12-01 06:53:23 26 4
gpt4 key购买 nike

假设您有以下 HTML 表单:

<form method="POST">        
<select class="form-control" id="startyear" name="startyear">
<option value="2005">first</option>
<option value="2006">second</option>
<option value="2007">third</option></select>
</form>

我知道为了访问 flask 中选择字段的,需要请求:

len = request.form.get(startyear)

但是,通过这种方式,我们可以获得值,例如“2005”、“2006”等。有没有办法获得这些值的名称?那么“第一”、“第二”等等?谢谢您

最佳答案

您可以在此处找到详细信息select developer.Mozilla

Each option element should have a value attribute containing the data value to submit to the server when that option is selected; if no value attribute is included, the value defaults to the text contained inside the element

所以获取文本:不要设置值,如果设置了值,就会得到它

关于python - 如何请求选择标签名称选择,而不是 flask 中的值选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58904789/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com