相关疑难解决方法(0)

Python:拆分空格还是连字符?

在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定义似乎只指定了一个字符串.我需要使用正则表达式吗?

python string formatting

7
推荐指数
2
解决办法
2万
查看次数

标签 统计

formatting ×1

python ×1

string ×1