正则表达式在这里似乎有点矫枉过正。您可以使用sum生成器表达式:x = 'DOFLAMINGO WITH TOUCH SCREEN lorem ipsum'x_chars = ''.join(x.split()) # remove all whitespacex_upper = sum(i.isupper() for i in x_chars) > (len(x_chars) / 2)或功能上通过map:x_upper = sum(map(str.upper, x_chars)) > (len(x_chars) / 2)或者,通过statistics.mean:from statistics import meanx_upper = mean(i.isupper() for i in s if not i.isspace()) > 0.5