In the following examples, I am splitting an empty string by a space. However, in the first example I explicitly used a space and in the second example, I didn't. My understanding was that .split()
and .split(' ')
were equivalent.
Why do these two examples give different outputs?
In [1]: "".split(' ')
Out[1]: ['']
In [2]: "".split()
Out[2]: []
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…