如何拆分句子并将每个单词存储在列表中?例如
"these are words" ⟶ ["these", "are", "words"]
<小时/>
要按其他分隔符进行拆分,请参阅 Split a string by a delimiter in python .
要拆分为单个字符,请参阅 How do I split a string into a list of characters? .
最佳答案
给定一个字符串sentence
,它将每个单词存储在名为words
的列表中:
words = sentence.split()
关于python - 如何将字符串拆分为单词列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58879630/