:type s: str :rtype: int
(self, s)
| 25 | |
| 26 | class Solution(object): |
| 27 | def countSegments(self, s): |
| 28 | """ |
| 29 | :type s: str |
| 30 | :rtype: int |
| 31 | """ |
| 32 | s = s.strip() |
| 33 | if not s.strip(): |
| 34 | return 0 |
| 35 | |
| 36 | result = re.split(r'\s+', s) |
| 37 | |
| 38 | return len(result) |