如何选择单选按钮?

时间:2010-09-26 14:05:27

标签: python radio-button mechanize

我正在使用mechanize,我正在尝试从单选按钮列表中选择一个按钮。此列表有5个项目。如何选择第一项?文档没有帮助我。

>>> br.form
<ClientForm.HTMLForm instance at 0x9ac0d4c>
>>> print(br.form)
<form1 POST http://www.example.com application/x-www-form-urlencoded
<HiddenControl(DD=17010200) (readonly)>
<RadioControl(prodclass=[1, 2, 3, 4, 5])>
<SubmitControl(submit=text) (readonly)>>

1 个答案:

答案 0 :(得分:12)

It should be as simple as

br.form['prodclass'] = ['1']

我更喜欢更详细的:

br.form.set_value(['1'],name='prodclass')