【lc】434 字符串中的单词数

链接

https://leetcode.cn/problems/number-of-segments-in-a-string/description/

分析

直接split就好了。。

代码

class Solution:
    def countSegments(self, s: str) -> int:
        return s.split().__len__()

 

posted @ 2023-08-25 14:10  BJFU-VTH  阅读(5)  评论(0编辑  收藏  举报