我是python中的新成员。我使用以下格式的2d数组中的数据。
array[0] array[1]
Arkan Adrian Edmondson
Efgan All Rik
'Til Death Do Us Part (Star Trek: Deep Space Nine) Bradley Thompson
'Til Death Do Us Part (Star Trek: Deep Space Nine) David Weddle
Billy Sherrill 'Til I Can Make It on My Own (Deep Space)我想匹配一个文件中的每一行这个字符串,如果匹配这两个数组,然后我想返回该行。
首先,我要在每行中搜索这两个数组。为此,我的尝试是:
def strinMach(domainL, rangeR):
text = ""
filetext = open(File, "r").read()
sentlist = re.split(u'[\n|\r\n]+',filetext)
for i in sentlist:
if domainL in i and rangeR in i:
text = text + i + "\n"
elif (To search for without the parenthesis string from array[0] & array[1]
eg.search with (Til Death Do Us Part Bradley Thompson ) )
elif (To search with some string from array[0] & array[1]
es. search with(Till Death Bradley) or (Do Us Part Thompson))
return text我的第二步是除了括号字符串之外对数组进行筛选(即除了(术语)
)。
第三步用两个数组的子串。
如何继续进行2nd&第三步。
任何形式的帮助将不胜感激。
谢谢!!!!!!!