如何提取此列表的元素

时间:2015-12-04 09:30:36

标签: python list

我有一个这样的列表:

contents = [INSERT['new' at(41.74, 33.747)],
            INSERT['new' at(85.421, 34.221)],
            INSERT['new' at(57.848, 45.294)],
            INSERT['new' at(66.47, 19.93)],
            INSERT['new' at(70.071, 37.06)],
            INSERT['new' at(87.979, 22.958)],
            INSERT['new' at(46.098, 24.473)],
            LWPOLYLINE[((58.805, 38.48), (56.436, 23.622))],
            LWPOLYLINE[((68.375, 28.732), (79.556, 22.013))],
            LWPOLYLINE[((101.065, 41.603), (101.065, 29.3))],
            LINE[(99.644, 26.272) to(109.593, 36.02)],
            LINE[(97.938, 15.388) to(108.55, 18.132)],
            LINE[(87.231, 11.129) to(71.502, 15.388)]]

我想要的是从每个元素中提取数字来操纵它,当我调用contents[0]时,我只有INSERT['new' at (57.848, 45.294)]并且我不知道这个元素的结构是什么来操纵它

1 个答案:

答案 0 :(得分:-1)

您必须迭代地遍历项目列表

    for con in contents:
      item = contents[con] # this will give each item of a list
        #then here apply your logic