regex 将在所有出现逗号(这是位于 regex 开头的逗号)的位置做出断言:“前面是不是没有引号或者前面的引号个数是否为偶数”?
The regex makes an assertion at every occurrence of a comma (that's the comma at the very beginning of the regex): "Are no quotes ahead or is an even number of quotes ahead?"
实现相同结果的另一种方法是测试tuple中的当前项是否是偶数(使用if not num % 2:),如果为真,那么将当前项添加到运行总和中。
An alternative method to accomplish the same result would test whether the current item in the tuple is even (using if not num % 2:) and, if true, would add the current item to the running total.
应用推荐