python 如何判断获取列表中元组的第一个值或者把列表转换为字典

由于程序中列表的获取来自excel表,只复制代码也不起作用,就直接上图片了

img

你的 需求有两种方法可以实现
1、输入国家后遍历  freight 
      for res in freight:
         if res(0) == country_1:
             print("数据",res)
             break

2、freight 生成时,直接存为字典 , {'国家1':'2.03','国家2','2.11'}这种形式
你就可以这样用 
if country_1 in freight :
    print("数据", country_1 [freight ])

freight = dict(freight) 搞了半天,原来只要这样就可以了!