我正在寻找 Python 等价物
String str = "many fancy word \nhello \thi"; String whiteSpaceRegex = "\\s"; String[] words = str.split(whiteSpaceRegex); ["many", "fancy", "word", "hello", "hi"]
没有参数的str.split()方法在空格上拆分:
str.split()
>>> "many fancy word \nhello \thi".split() ['many', 'fancy', 'word', 'hello', 'hi']