Python 我怎样才能把每个单词放在一个字符串中,并将其附加到一个列表中?

Python 我怎样才能把每个单词放在一个字符串中,并将其附加到一个列表中?,python,string,list,Python,String,List,我的字符串是: wish = "Happy New Year" 输出: word_list = ['Happy','New','Year'] 请参见字符串的拆分方法 "Happy New Year".split() 这将生成您的阵列 >>> wish = "Happy New Year" >>> wordlist = wish.split() >>> wordlist ['Happy', 'New', 'Year'] >>&

我的字符串是:

wish = "Happy New Year"
输出:

word_list = ['Happy','New','Year']

请参见字符串的拆分方法

"Happy New Year".split()
这将生成您的阵列

>>> wish = "Happy New Year"
>>> wordlist = wish.split()
>>> wordlist
['Happy', 'New', 'Year']
>>>
您可以看到string函数split的帮助

>>> help(''.split)
Help on built-in function split:

split(...)
    S.split([sep [,maxsplit]]) -> list of strings

    Return a list of the words in the string S, using sep as the
    delimiter string.  If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified or is None, any
    whitespace string is a separator and empty strings are removed
    from the result.

>>>

你在这方面的尝试是什么?这不是编码服务。我觉得自己像个白痴,但谢谢你,不要对自己太苛刻了。:)我们都去过那里