Split函数,用来返回一个下标从零开始的一维数组,如下举例说明

1、split(' '),''号中间是空格

def break_words(stuff):
    """This function will break up words for us"""
    words=stuff.split(' ')
    return words

返回的words应该是This function will break up words for us

 

2、Split('&'),''号中间是&

def break_words(stuff):

    """This&function&will&break&up&words&for&us"""

    words=stuff.split('&')

    return words

返回的words也应该是This function will break up words for us

 

备注:区别在于split后边括号跟的啥,就由啥符号将字符串分开为单个的字符

相关文章:

  • 2021-10-17
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2021-05-19
猜你喜欢
  • 2021-12-26
  • 2021-09-26
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-29
相关资源
相似解决方案