Python中空格上的拆分字符串[duplicate]

  • 问题:
  • 我在找Python的等价物

    String str = "many   fancy word \nhello    \thi";
    String whiteSpaceRegex = "\\s";
    String[] words = str.split(whiteSpaceRegex);

    ["many", "fancy", "word", "hello", "hi"]

  • 答案:
  • 结构分裂()没有参数的方法在空格上拆分:

    >>> "many   fancy word \nhello    \thi".split()
    ['many', 'fancy', 'word', 'hello', 'hi']