![]() |
От: |
Гест
|
https://zverok.github.io |
Дата: | 06.03.09 12:52 | ||
Оценка: |
54 (4)
![]() |
>>>> "1 2".split()
SH>['1', '2']
SH>
>>>> "1 2".split(" ")
SH>['1', '', '', '', '2']
SH>
>>>> "1 2 3 4 5".split(" ") # так работает неправильно
SH>['1', '', '', '', '2', '', '', '3', '4', '5']
>>>> "1 2 3 4 5".split() # так правильно
SH>['1', '2', '3', '4', '5']
>>>> "1 2 3 4 5".split(maxsplit=2) # но не указать количество
SH>Traceback (most recent call last):
SH> File "<stdin>", line 1, in <module>
SH>TypeError: split() takes no keyword arguments
SH>
For example, ' 1 2 3 '.split() returns ['1', '2', '3'], and ' 1 2 3 '.split(None, 1) returns ['1', '2 3 '].
http://docs.python.org/library/stdtypes.html