class Solution: def lengthOfLastWord(self, s: str) -> int: if s==‘ ‘*len(s): return 0 if ‘ ‘ not in s: return len(s) a=s.split(‘ ‘) i=-1 while a[i]==‘‘: i-=1 return len(a[i])
leetcode——58. 最后一个单词的长度
原文:https://www.cnblogs.com/taoyuxin/p/11688537.html