Python中按空格拆分字符串
- 论坛
- Python中按空格拆分字符串
107 浏览
Python中按空格拆分字符串
这个问题已经有答案了:
我正在寻找Python语言中等价的
String str = "many fancy word \nhello \thi"; String whiteSpaceRegex = "\\s"; String[] words = str.split(whiteSpaceRegex); ["many", "fancy", "word", "hello", "hi"]
admin 更改状态以发布 2023年5月23日
匿名的
0 Comments
str.split()
方法不带参数会按照空格进行分割:
>>> "many fancy word \nhello \thi".split() ['many', 'fancy', 'word', 'hello', 'hi']