Questions tagged «text-segmentation»

9
如何将字符串拆分为列表?
我希望我的Python函数拆分一个句子(输入)并将每个单词存储在列表中。我当前的代码拆分了句子,但没有将单词存储为列表。我怎么做? def split_line(text): # split the text words = text.split() # for each word in the line: for word in words: # print the word print(words)


13
将字符串转换为单词列表?
我正在尝试使用python将字符串转换为单词列表。我想采取以下措施: string = 'This is a string, with words!' 然后转换成这样的东西: list = ['This', 'is', 'a', 'string', 'with', 'words'] 注意省略了标点符号和空格。最快的解决方法是什么?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.