Python3: 无法从已解析的数据中拆分单词

Python3: Unable to split word from parsed data

我正在创建一个 MapReduce 作业以从 XML 文件中查找 'ArticleTitle'。我正在研究 mapper.py 来识别标签并根据字母拆分标签。 以下是脚本:

tree = ET.parse('File location')
doc = tree.getroot()
for ArticleTitle in doc.iter('ArticleTitle'):
    file1 = (ET.tostring(ArticleTitle, encoding='utf8').decode('utf8'))
    filename = file1[52:(len(file1))]
    Article_Title= filename.split("<")[0]
    # print(Article_Title)
    for line in Article_Title:
        line_1= re.findall(r"\w+|[^\w\s]", line, re.UNICODE)
        print(line_1)

我得到的输出是:

['T']['h']['e'][]['e']['f']['f']['e']['c']['t'][]['o']['f']

但是,我希望输出为:

['The', 'effect', 'of', 'Hene', 'laser']

Article Title 是一个字符串。参见:

Article_Title= filename.split("<")[0]

如果你遍历一个字符串,你会得到单独的字符。

for i in "hello!":
    print(i)

>>>>h
>>>>e
>>>>l
>>>>l
>>>>o
>>>>!

如果你想要整个单词,你不需要循环 - 只需要 Article_Title.split()

"The effect of Hene laser" --> ['The', 'effect', 'of', 'Hene', 'laser']