【发布时间】:2019-11-01 00:18:06
【问题描述】:
我需要来自 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)
【问题讨论】:
标签: python json regex python-3.x filter