code_junkie

string.split(text) or text.split() what's the diference?

Nov 12th, 2011
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. string.split(text)
  2.  
  3. text.split()
  4.  
  5. >>> import string
  6. >>> help(string.split)
  7. Help on function split in module string:
  8.  
  9. split(s, sep=None, maxsplit=-1)
  10. split(s [,sep [,maxsplit]]) -> list of strings
  11.  
  12. Return a list of the words in the string s, using sep as the
  13. delimiter string. If maxsplit is given, splits at no more than
  14. maxsplit places (resulting in at most maxsplit+1 words). If sep
  15. is not specified or is None, any whitespace string is a separator.
  16.  
  17. (split and splitfields are synonymous)
  18.  
  19. >>> help("".split)
  20. Help on built-in function split:
  21.  
  22. split(...)
  23. S.split([sep [,maxsplit]]) -> list of strings
  24.  
  25. Return a list of the words in the string S, using sep as the
  26. delimiter string. If maxsplit is given, at most maxsplit
  27. splits are done. If sep is not specified or is None, any
  28. whitespace string is a separator.
  29.  
  30. 'a b c'.split()
  31. str.split('a b c')
  32.  
  33. # both return ['a', 'b', 'c']
Add Comment
Please, Sign In to add comment