我正在寻找与
等效的 PythonString str = "many fancy word \nhello \thi";
String whiteSpaceRegex = "\\s";
String[] words = str.split(whiteSpaceRegex);
["many", "fancy", "word", "hello", "hi"]
最佳答案
str.split()
没有参数的方法在空格上拆分:
>>> "many fancy word \nhello \thi".split()
['many', 'fancy', 'word', 'hello', 'hi']
关于python - 在 Python 中的空格上拆分字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8113782/