在Python中,如何拆分空格或连字符?
输入:
You think we did this un-thinkingly?
Run Code Online (Sandbox Code Playgroud)
期望的输出:
["You", "think", "we", "did", "this", "un", "thinkingly"]
Run Code Online (Sandbox Code Playgroud)
我可以得到
mystr.split(' ')
Run Code Online (Sandbox Code Playgroud)
但我不知道如何拆分连字符和空格,并且拆分的Python定义似乎只指定了一个字符串.我需要使用正则表达式吗?