如果我有相同的多个键,如何从 WTForms 中的 SelectField 获取值(不是键)数据?
How to get value (not key) data from SelectField in WTForms if i have same multiple key?
deliveryMethod = SelectField('Delivery method/Channel', choices = [(1, 'Accounts opened with adequate CDD measures carried out'),(1,'Delivery channels linked with accounts opened with adequate CDD measures carried out'),(2, 'Product serviced by agents'),(2,'Certificate of Deposit'),(4,'Non face-to-face customers'),(4,'Mobile/Internet banking facilities not linked with accounts'),(4,'Products served with unregistered beneficiaries')])
听说选项有多个相同的 key.i 想从中获取非键值,如何获取这个非键值?
Choices 是一个元组列表。如果你只想要 "values",试试这个:
values = [x[-1] for x in form.deliveryMethod.choices]
deliveryMethod = SelectField('Delivery method/Channel', choices = [(1, 'Accounts opened with adequate CDD measures carried out'),(1,'Delivery channels linked with accounts opened with adequate CDD measures carried out'),(2, 'Product serviced by agents'),(2,'Certificate of Deposit'),(4,'Non face-to-face customers'),(4,'Mobile/Internet banking facilities not linked with accounts'),(4,'Products served with unregistered beneficiaries')])
听说选项有多个相同的 key.i 想从中获取非键值,如何获取这个非键值?
Choices 是一个元组列表。如果你只想要 "values",试试这个:
values = [x[-1] for x in form.deliveryMethod.choices]