我有一个包含省数据的元组。
CHOICES = (
('', ''),
('United States', (
('AL', 'Alabama'),
('AK', 'Alaska'),
('AZ', 'Arizona'),
('AR', 'Arkansas'),
('CA', 'California'),
('CO', 'Colorado'),
('CT', 'Connecticut'),
('DE', 'Delaware'),
('DC', 'District of Columbia'),
('FL', 'Florida'),
('GA', 'Georgia'),
('GU', 'Guam'),
('HI', 'Hawaii'),
('ID', 'Idaho'),
('IL', 'Illinois'),
('IN', 'Indiana'),
('IA', 'Iowa'),
('KS', 'Kansas'),
('KY', 'Kentucky'),
('LA', 'Louisiana'),
('ME', 'Maine'),
('MD', 'Maryland'),
('MA', 'Massachusetts'),
('MI', 'Michigan'),
('MN', 'Minnesota'),
('MS', 'Mississippi'),
('MO', 'Missouri'),
('MT', 'Montana'),
('NE', 'Nebraska'),
('NV', 'Nevada'),
('NH', 'New Hampshire'),
('NJ', 'New Jersey'),
('NM', 'New Mexico'),
('NY', 'New York'),
('NC', 'North Carolina'),
('ND', 'North Dakota'),
('OH', 'Ohio'),
('OK', 'Oklahoma'),
('OR', 'Oregon'),
('PA', 'Pennsylvania'),
('PR', 'Puerto Rico'),
('RI', 'Rhode Island'),
('SC', 'South Carolina'),
('SD', 'South Dakota'),
('TN', 'Tennessee'),
('TX', 'Texas'),
('UT', 'Utah'),
('VT', 'Vermont'),
('VA', 'Virginia'),
('VI', 'Virgin Islands'),
('WA', 'Washington'),
('WV', 'West Virginia'),
('WI', 'Wisconsin'),
('WY', 'Wyoming')
)
),
('Canada', (
('AB', 'Alberta' , 1.05),
('BC', 'British Columnbia', 1.12),
('MB', 'Manitoba', 1.05),
('NB', 'New Brunswick', 1.13),
('NL', 'Newfoundland and Labrador', 1.13),
('NT', 'Northwest Territories', 1.05),
('NS', 'Nova Scotia', 1.15),
('NU', 'Nunavut', 1.05),
('PE', 'Prince Edward Island', 1.05),
('SK', 'Saskatchewan', 1.05),
('ON', 'Ontario', 1.13),
('QC', 'Quebec', 1.05),
('YT', 'Yukon', 1.05)
)
)
)
如果选择了加拿大省,是否有一种基于省代码获取号码的优雅方法。例子。如果我将省设置为 ON,是否可以使用元组操作来获取值 1.13。
谢谢。