我有一个Python 3.7.3文件specs.py
,其中包含多个具有相同键的字典。
f150 = {
'towing-capacity' : '3,402 to 5,897 kg','horsepower' : '385 to 475 hp','engine' : ' 2.7 L V6,3.3 L V6,3.5 L V6,5.0 L V8'
}
f250 = {
'towing-capacity' : '5,670 to 5,'horsepower' : '290 to 450 hp','engine' : '6.2 L V8,6.7 L V8 diesel,7.3 L V8'
}
在另一个文件中,我正在导入specs.py
,并希望能够找到与变量carmodel
的给定键关联的值。
hp = specs.{what should I put here so it equals cardmodel}.['horsepower']