python代码如下
class Solution:
def detectCapitalUse(self, word: str) -> bool:
b=len(word)
a=0
a1=0
for i in word:
if i>='A' and i<='Z': a+=1
elif i>='a' and i<='z':a1+=1
if(a1==b ): return True
elif(a==b) : return True
elif(a==1 and word[0]>='A' and word[0]<='Z' ) :return True
else: return False