小编fur*_*ame的帖子

如何在Scala中测试字符串是否在python中具有大写字母

在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)

有点笨拙.有没有更好的方法来做到这一点?(它只是一个脑筋急转弯并不重要:)

python functional-programming scala

2
推荐指数
1
解决办法
2223
查看次数

标签 统计

functional-programming ×1

python ×1

scala ×1