简体   繁体   English

如何从具有 python 中各种列表的字符串列表中提取信息

[英]how to extract information from a list of strings with various lists in python

I have a splits list of strings as follows:我有一个splits字符串列表,如下所示:

splits = ['Heading_Error(deg):<br>    base = 60.760321610086216<br>    feature = 119.09070043133725<br>    scene', '5G21A6P00L4100037:1566448100150275<br>    object', "['f528bf65-9028-443d-8288-1efcd5c837cd', 'eb71c9c8-3924-4038-822f-0ac0508eb02c', 'e1f2c84b-fb37-4e33-8b5b-4f37d354d326']<br>    cloud_uuid_feature = ['5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275']<br>"]

How can I extract the following fields?如何提取以下字段?

scene = "5G21A6P00L4100037:1566448100150275"
objects = [
   'f528bf65-9028-443d-8288-1efcd5c837cd',
   'eb71c9c8-3924-4038-822f-0ac0508eb02c',
   'e1f2c84b-fb37-4e33-8b5b-4f37d354d326'
]
cloud_uuid_feature = [
   '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', 
   '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', 
   '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275'
]

objects are a list of strings, cloud_uuid_feature is a list of string objects 是一个字符串列表,cloud_uuid_feature 是一个字符串列表

Hoping the structure of your message holds good.希望您的信息结构保持良好。 I am joining the splits into a single string and find the necessary data.我将拆分加入单个字符串并找到必要的数据。

import re
st=''.join(splits)
scene = re.findall('scene([^<]*)<br>',st)[0]
/// result '5G21A6P00L4100037:1566448100150275'

objects_str = re.findall('object\[([^\]]*)\]',st)[0]
objects=[x.strip().strip("'") for x in objects_str.split(',')]
/// result ['f528bf65-9028-443d-8288-1efcd5c837cd', 'eb71c9c8-3924-4038-822f-0ac0508eb02c', 'e1f2c84b-fb37-4e33-8b5b-4f37d354d326']

clouds_str = re.findall('cloud_uuid_feature.*\[([^\]]*)\]',st)[0]
cloud_uuid_feature = [x.strip().strip("'") for x in clouds_str.split(',')]
/// result ['5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275', '5G21A6P00L4100037:1566448099:1566448119-lidar_roof_left-1566448100150275']

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM