convert the value of dictionary from list to float

前端 未结 3 1540
陌清茗
陌清茗 2021-01-21 11:00

I have a dictionary named \"location\" like this:

{
    \'WA\': [
        \'47.3917\',
        \'-121.5708\'
    ],
    \'VA\': [
        \'37.7680\',
        \'         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-21 11:31

    Your problem is in here: float(location[key][0,1])

    # float objects are length 1
    for key in location.keys():
        location[key] = [float(location[key][0]),float(location[key][1])]
    print location
    

提交回复
热议问题