Count the number of words in the string, the word here refers to the continuous character is not a space.
Note that you can assume that the string was does not include any non-printable characters.
Example:
Enter: "Hello, my name is John "
Output: 5
class Solution(object): def countSegments(self, s): """ :type s: str :rtype: int """ s = s.split() return len(s)
split () is sliced by specifying a string delimiter, if the parameter value is specified num, num + 1 sub-string is separated.
str - separator, default for all null characters, including spaces, linefeed (\ n-), tab (\ t), etc.