If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace. Consequently, splitting an empty string or a string consisting of just whitespace with a None separator returns [].
.split()
如果没有参数,则在运行任何连续的空白字符时将拆分。你知道吗因此它会自动将“\n”视为单个2字符分隔符。你知道吗
.split(' ')
使用一个参数,现在将仅在空格字符上拆分。你知道吗发件人:https://docs.python.org/3.7/library/stdtypes.html#str.split
除了奖金:
.split()
没有参数可以确保:''
(空)或任何空白标记这两个都是真正很好的节省时间。你知道吗
相关问题 更多 >
编程相关推荐