上代码:
url = "https://mp.csdn.net/postedit"
url_list = url.split('/')
print(url_list)
把url按照 '/' 切分,生成的list赋值给url_list,结果如下:
['https:', '', 'mp.csdn.net', 'postedit']
源码里对split函数的解释:
def split(self, sep=None, maxsplit=-1): # real signature unknown; restored from __doc__
"""
S.split(sep=None, maxsplit=-1) -> list of strings
Return a list of the words in S, using sep as the
delimiter string. If maxsplit is given, at most maxsplit
splits are done. If sep is not specified or is None, any
whitespace string is a separator and empty strings are
removed from the result.
"""
return []