从包含数字和单词的列表创建表

pnwntuvh  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(227)

我以这种方式使用循环创建打印输出:

new_coordinates = [[14.292429, 47.557149], [14.292429, 47.557149], [14.292429, 47.557149], [14.29902, 47.552474], [14.29902, 47.552474], [14.332263, 47.52663], [14.332263, 47.52663], [14.333375, 47.525116], [14.333375, 47.525116], [14.338493, 47.525643], [14.338493, 47.525643], [14.335595, 47.525614], [14.335595, 47.525614], [14.314937, 47.574178], [14.314937, 47.574178], [14.318924, 47.575619], [14.318924, 47.575619], [14.314233, 47.573812], [14.314233, 47.573812], [14.31484, 47.574285], [14.31484, 47.574285], [14.29902, 47.552474]]       

new_coords = zip(new_coordinates[0:], new_coordinates[1:])

        for c1, c2 in new_coords:

            body = {"coordinates":[c1, c2],"extra_info":["waycategory"]}

            headers = {
            'Accept': 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8',
            'Content-Type': 'application/geo+json; charset=utf-8'
            }
            call = requests.post('http://127.0.0.1:8080/ors/v2/directions/driving-hgv/geojson', json=body, headers=headers)
            weiter = call.text
            data = json.loads(weiter)

            Waycategory = data['features'][0]['properties']['extras']['waycategory']['summary']

            for wc in Waycategory:
                print(wc['value'])

            for wc in Waycategory:
                print(wc['amount'])

            Duration = data['features'][0]['properties']['summary']['duration']

            print(Duration)

        print('ArriveAtLocation')

输出如下所示:

0.0
100.0
471.0
ArriveAtLocation
3.0
1.0
0.0
82.65
12.44
4.92
872.6
3.0
100.0
195.8
1.0
3.0
99.75
0.25
14.4
0.0
100.0
25.9
1.0
3.0
99.69
0.31
20.4
3.0
100.0
334.8
1.0
3.0
99.78
0.22
31.6
0.0
1.0
99.43
0.57
27.8
3.0
1.0
0.0
92.82
6.05
1.13
1811.0
3.0
100.0
130.5
ArriveAtLocation
3.0
100.0
11266.9
ArriveAtLocation
0.0
3.0
99.76
0.24
151.7
ArriveAtLocation
0.0
3.0
99.96
0.04
150.1
ArriveAtLocation
3.0
100.0
8138.6
ArriveAtLocation
3.0
100.0
165.1
1.0
0.0
3.0
99.66
0.33
0.0
20.3
0.0
100.0
14.1
1.0
100.0
17.1
3.0
1.0
99.95
0.05
451.5
1.0
100.0
67.6
0.0
100.0
7.7
1.0
3.0
0.0
99.51
0.49
0.0
47.4
3.0
100.0
273.1
3.0
1.0
0.0
87.83
10.75
1.42
1075.6
ArriveAtLocation
3.0
1.0
100.0
0.0
3059.0
ArriveAtLocation
3.0
100.0
130.0
1.0
3.0
99.78
0.22
31.6
0.0
1.0
99.43
0.57
27.8
3.0
1.0
0.0
92.82
6.05
1.13
1811.0
3.0
100.0
89.3
1.0
3.0
99.89
0.11
75.1
ArriveAtLocation
0.0
100.0
502.2
ArriveAtLocation
0.0
100.0
471.0
ArriveAtLocation
3.0
1.0
0.0
82.65
12.44
4.92
872.6
3.0
100.0
195.8
1.0
3.0
99.75
0.25
14.4
0.0
100.0
25.9
1.0
3.0
99.69
0.31
20.4
3.0
100.0
334.8
1.0
3.0
99.78
0.22
31.6
0.0
1.0
99.43
0.57
27.8
3.0
1.0
0.0
92.82
6.05
1.13
1811.0
3.0
100.0
130.5
ArriveAtLocation
3.0
1.0
100.0
0.0
10622.2
ArriveAtLocation
1.0
3.0
99.91
0.09
88.0
ArriveAtLocation
3.0
100.0
85.1
ArriveAtLocation
1.0
3.0
99.89
0.11
36.4
ArriveAtLocation
0.0
1.0
100.0
0.0
358.9
ArriveAtLocation

​现在我需要得到一个形状,在那里它是实际可用的,例如在matlab中。我听说你可以从列表中打印到表中。因此,我的猜测是将上述内容打印到单独的列表中,然后将其导出到一个表中。
第一步,创建列表:

value_list = []

        for wc in Waycategory:
            value_list.append(wc['value'])

        amount_list = []

        for wc in Waycategory:
            amount_list.append(wc['amount'])

        Duration = data['features'][0]['properties']['summary']['duration']

        duration_list = []

        duration_list.append(Duration)

        print(value_list)
        print(amount_list)
        print(duration_list)

    print('ArriveAtLocation')

得到:

[0.0]
[100.0]
[471.0]
ArriveAtLocation
[3.0, 1.0, 0.0]
[82.65, 12.44, 4.92]
[872.6]
[3.0]
[100.0]
[195.8]
[1.0, 3.0]
[99.75, 0.25]
[14.4]
[0.0]
[100.0]
[25.9]
[1.0, 3.0]
[99.69, 0.31]
[20.4]
[3.0]
[100.0]
[334.8]
[1.0, 3.0]
[99.78, 0.22]
[31.6]
[0.0, 1.0]
[99.43, 0.57]
[27.8]
[3.0, 1.0, 0.0]
[92.82, 6.05, 1.13]
[1811.0]
[3.0]
[100.0]
[130.5]
[3.0]
[100.0]
[195.8]
[1.0, 3.0]
[99.75, 0.25]
[14.4]
[0.0]
[100.0]
[25.9]
[1.0, 3.0]
[99.69, 0.31]
[20.4]
[3.0]
[100.0]
[334.8]
[1.0, 3.0]
[99.78, 0.22]
[31.6]
[0.0, 1.0]
[99.43, 0.57]
[27.8]
[3.0, 1.0, 0.0]
[92.82, 6.05, 1.13]
[1811.0]
[3.0]
[100.0]
[326.2]
[1.0, 3.0]
[99.75, 0.25]
[14.4]
[0.0]
[100.0]
[25.9]
[1.0, 3.0]
[99.69, 0.31]
[20.4]
[3.0]
[100.0]
[806.8]
[3.0, 1.0, 0.0]
[84.78, 14.34, 0.89]
[517.0]
[0.0]
[100.0]
[1.0]
[1.0, 3.0]
[99.44, 0.56]
[38.5]
[3.0]
[100.0]
[495.0]
[3.0]
[100.0]
[130.5]
ArriveAtLocation
[3.0]
[100.0]
[11266.9]
ArriveAtLocation
[0.0, 3.0]
[99.76, 0.24]
[151.7]
ArriveAtLocation
[0.0, 3.0]
[99.96, 0.04]
[150.1]
ArriveAtLocation
[3.0]
[100.0]
[8138.6]
ArriveAtLocation
[3.0]
[100.0]
[165.1]
[1.0, 0.0, 3.0]
[99.66, 0.33, 0.0]
[20.3]
[0.0]
[100.0]
[14.1]
[1.0]
[100.0]
[17.1]
[3.0, 1.0]
[99.95, 0.05]
[451.5]
[1.0]
[100.0]
[67.6]
[0.0]
[100.0]
[7.7]
[1.0, 3.0, 0.0]
[99.51, 0.49, 0.0]
[47.4]
[3.0]
[100.0]
[273.1]
[3.0]
[100.0]
[165.1]
[1.0, 0.0, 3.0]
[99.66, 0.33, 0.0]
[20.3]
[0.0]
[100.0]
[14.1]
[1.0]
[100.0]
[17.1]
[3.0, 1.0]
[99.95, 0.05]
[451.5]
[1.0]
[100.0]
[67.6]
[0.0]
[100.0]
[7.7]
[1.0, 3.0, 0.0]
[99.51, 0.49, 0.0]
[47.4]
[3.0]
[100.0]
[273.1]
[3.0, 1.0, 0.0]
[87.83, 10.75, 1.42]
[1075.6]
ArriveAtLocation
[3.0, 1.0]
[100.0, 0.0]
[3059.0]
ArriveAtLocation
[3.0]
[100.0]
[130.0]
[1.0, 3.0]
[99.78, 0.22]
[31.6]
[0.0, 1.0]
[99.43, 0.57]
[27.8]
[3.0, 1.0, 0.0]
[92.82, 6.05, 1.13]
[1811.0]
[3.0]
[100.0]
[326.2]
[1.0, 3.0]
[99.75, 0.25]
[14.4]
[0.0]
[100.0]
[25.9]
[1.0, 3.0]
[99.69, 0.31]
[20.4]
[3.0]
[100.0]
[806.8]
[3.0, 1.0, 0.0]
[84.78, 14.34, 0.89]
[517.0]
[0.0]
[100.0]
[1.0]
[1.0, 3.0]
[99.44, 0.56]
[38.5]
[3.0]
[100.0]
[495.0]
[3.0]
[100.0]
[89.3]
[1.0, 3.0]
[99.89, 0.11]
[75.1]
ArriveAtLocation
[0.0]
[100.0]
[502.2]
ArriveAtLocation
[0.0]
[100.0]
[471.0]
ArriveAtLocation
[3.0, 1.0, 0.0]
[82.65, 12.44, 4.92]
[872.6]
[3.0]
[100.0]
[195.8]
[1.0, 3.0]
[99.75, 0.25]
[14.4]
[0.0]
[100.0]
[25.9]
[1.0, 3.0]
[99.69, 0.31]
[20.4]
[3.0]
[100.0]
[334.8]
[1.0, 3.0]
[99.78, 0.22]
[31.6]
[0.0, 1.0]
[99.43, 0.57]
[27.8]
[3.0, 1.0, 0.0]
[92.82, 6.05, 1.13]
[1811.0]
[3.0]
[100.0]
[130.5]
[3.0]
[100.0]
[195.8]
[1.0, 3.0]
[99.75, 0.25]
[14.4]
[0.0]
[100.0]
[25.9]
[1.0, 3.0]
[99.69, 0.31]
[20.4]
[3.0]
[100.0]
[334.8]
[1.0, 3.0]
[99.78, 0.22]
[31.6]
[0.0, 1.0]
[99.43, 0.57]
[27.8]
[3.0, 1.0, 0.0]
[92.82, 6.05, 1.13]
[1811.0]
[3.0]
[100.0]
[326.2]
[1.0, 3.0]
[99.75, 0.25]
[14.4]
[0.0]
[100.0]
[25.9]
[1.0, 3.0]
[99.69, 0.31]
[20.4]
[3.0]
[100.0]
[806.8]
[3.0, 1.0, 0.0]
[84.78, 14.34, 0.89]
[517.0]
[0.0]
[100.0]
[1.0]
[1.0, 3.0]
[99.44, 0.56]
[38.5]
[3.0]
[100.0]
[495.0]
[3.0]
[100.0]
[130.5]
ArriveAtLocation
[3.0, 1.0]
[100.0, 0.0]
[10622.2]
ArriveAtLocation
[1.0, 3.0]
[99.91, 0.09]
[88.0]
ArriveAtLocation
[3.0]
[100.0]
[85.1]
ArriveAtLocation
[1.0, 3.0]
[99.89, 0.11]
[36.4]
ArriveAtLocation
[0.0, 1.0]
[100.0, 0.0]
[358.9]
ArriveAtLocation

注意,duration表示所有值的持续时间-我计划在matlab中根据它们的百分比来更改它们。所以我想我需要的是以下输出:

Value Amount Duration
    0   100.00 471
    AaL AaL    AaL
    3    82.65 872.6
    1    12.44 872.6
    0     4.92 872.6
    3   100.00 195.8
    1    99.75  14.4
    3     0.25  14.4

我不知道怎么去那里-和你分手 ArriveAtLocation 是一个问题,但重要的是要知道我何时到达一个地点。我希望这显示出足够的努力,我想去的地方-谁能提示我一个方法到那里?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题