一些数据包含一个我想要删除的额外空格,但不幸的是,那时它是一个匹配对象,所以我该如何删除它呢?
for string in sl:
for keyword in keywordList: #looping through each string in syslog.txt against each keyword in keyword.txt
if keyword in string:
hostnameResult = re.search(r"\s[A-z]+\s", string)
dateResult = re.search(r"^[A-Z][a-z][a-z]\s\s[0-9]+\s[0-9]{2}\:[0-9]{2}\:[0-9]{2}", string)
del(dateResult[3]) <- the part I'm trying to actually do.
print "**"+keyword+"**"+hostnameResult.group(0)+dateResult.group(0)