Python-如何将字符串拆分为列表?
发布于 2021-02-02 23:24:01
我希望我的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)
python list split
关注者
0
被浏览
298
1 个回答