Strings

split(string, sep=None, maxsplit=-1)

Create a list of words in string separated by sep.

Parameters:
  • string (str) – The string to split.

  • separator (str, optional) – The separator delimiting words. If not specified or None, splits at whitespace.

  • maxsplit (int, optional) – The maximum number of splits to complete. If not specified or -1, all possible splits are made.

Returns:

A list containing the words after splitting.

Return type:

list

strip(string, chars=None)

Remove characters in chars from beginning and end of string.

Parameters:
  • string (str) – the string to strip.

  • chars (str, optional) – string of characters to strip. If not specified or None, strips whitespace.

Returns:

a new string with characters stripped.

Return type:

str