我正在尝试将值保存到列表中,但是当我这样做时,它为我提供了None值。不知道我到底在做什么错
for sentence in mylist:
global typ,DN,pn
matches = re.finditer(regex_f,sentence,re.MULTILINE | re.IGNORECASE)
for matchNum,match in enumerate(matches,start=1):
subst = sentence[match.end():]
pn_matches = re.findall(regexp,subst,re.MULTILINE | re.IGNORECASE)
if len(pn_matches) > 0:
pn = pn_matches
pn_p = ("{pn}".format(flansch=match.group(),pn=pn))
print(pn)
list_test = []
dat_test = list_test.append(pn)
print(dat_test)
else:
pn_p = '?'
print("no PN found".format(flansch=match.group()))
['PN10']
None
['PN16']
None
['PN 40']
None
如果我直接从pn打印其工作值,但是当我将其附加到列表时,它会显示None。