我需要Symantec WSS的筛选字符串数据, 我只得到了没有键的值。 所以我想我自己试着行动,把每个空间都分开
原始数据示例:
9777 10/30/2019 08:10:10 192.168.1.2 "Virus Found" Scott Sampson
我想要JSON的结果:
{
"pid":"9777",
"timestamp":"10/30/2019 08:10:10",
"ip":"192.168.1.2",
"message":"Virus Found",
"first_name":"Scott",
"first_name":"Sampson"
}
我开始编写代码,但我卡住了:
data = r'''9777 10/30/2019 08:10:10 192.168.1.2 "Virus Found" Scott Sampson'''
ls1 = []
text = ""
for x in data:
if x is '"':
ls1.append('"')
else:
ls1.append(x)
print(ls1)
尝试使用正则表达式。使用命名组,可以直接从match对象获取字典
regex101 example
相关问题 更多 >
编程相关推荐