HTML - Python如何访问表单元素?
问题描述:
试图建立我自己的网络邮件客户端。 我得到它看起来像这样HTML - Python如何访问表单元素?
<form name="input" action="test2.py" methog="get" class="form">
<input type="text" name="Username" placeholder="Username">
<input type="password" name="Pass" placeholder="Password">
<button type="submit" id="login-button">Login</button>
</form>
想通过GET方法& &通行证获得点击输入用户名上的按钮,以填补这串代码在Python Web部件的模板。
user = ???(Username)
pass = ???(Pass)
并打印到一个新的空白html文件thoses var的值。
python的新东西,所以我尝试的一切似乎失败。
答
您应该使用method="post"
,它不会与GET
方法(但它拼写错误,你写了“methog”)。
https://docs.python.org/2/library/cgi.html#using-the-cgi-module – Rishav
excatly我做了什么...但似乎不工作点击。我需要一些Js吗? – Ragnar
我不这么认为..你能粘贴你当前的Python代码吗? – Rishav