weixin_39829501的博客我希望我的python函数分割一个句子(输入)并将每个单词存储在一个列表中。我当前的代码将句子拆分,但不将单词存储为列表。我该怎么做?12345678910def split_line(text):# split the textwords = text.split()# for ...
字符串的分割可以通过`split()`方法实现,它根据指定的分隔符将字符串拆分成一个列表。例如: ```python str = 'a,b,c,d' str_list = str.split(',') for item in str_list: print(item) # 输出: # a # b # c # d...