目前,我正在学习型“任何”,在迅速而想出了下面的代码 let optionalDouble: Double? = 45.1
let things: [Any] = [
0,
0.0,
1.1,
optionalDouble, //expression implicitly coerced from Double? to Any
-4.0,
我玩弄然后我注意到了这一点: >>> l = input().split()
1 25 11 4
>>> any(s == s[::-1] for s in l)
True
>>> s == s[::-1] for s in l
SyntaxError: invalid syntax
>>>
为什么any(s == s[::-1] for s in l)工作,如果s == s[::
我正在Python中工作,使用any()这样来寻找String[]数组与从Reddit的API中提取的评论之间的匹配。 目前,我正在做这样的: isMatch = any(string in comment.body for string in myStringArray)
但是,这也将是有益的不只是知道isMatch是真实的,但它是其中的myStringArray元素进行了比赛。有没有办法用