在Scala中,我可以测试一个字符串是否有这样的大写字母:
val nameHasUpperCase = name.exists(_.isUpper)
Run Code Online (Sandbox Code Playgroud)
Python中我能想到的最全面的形式是:
a ='asdFggg'
functools.reduce(lambda x, y: x or y, [c.isupper() for c in a])
->True
Run Code Online (Sandbox Code Playgroud)
有点笨拙.有没有更好的方法来做到这一点?(它只是一个脑筋急转弯并不重要:)