官方python网站上的split功能如下split(pattern, string, maxsplit=0, flags=0)
但是当我在spyder上检查它时,它是split(sep=None, maxsplit=-1)
是否从python 3.6的split()函数中删除了字符串参数?
如果不是,那为什么不能在其中传递字符串arg?
最佳答案
第一个split
来自re
module
re.split(pattern, string, maxsplit=0, flags=0)
第二个是
str
methodstr.split(sep=None, maxsplit=-1)
调用
str.split
方法的方式是关闭str
对象,如下所示>>> s = 'this is a string'
>>> s.split(' ')
['this', 'is', 'a', 'string']
关于python - split()函数是否已更改,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42697949/