import random
from functools import reduce
import re
# the sum of number array
def sum(num_arr):
sum = reduce(lambda x,y:x+y,num_arr,0);
return sum
print(sum(range(1,11)))
# findall
# return the matched str
num_in_str = re.findall(r'\d+','123ssdf2323')
print(num_in_str)
# return group one in capture str
capture_group_one = re.findall(r"[^::\s]+[::]([^\s]+)","稿源:央视网 编辑:孙佩 发布时间:2017-09-15 15:31")
print(capture_group_one)
# return tuple array of groups in capture str
tuple_of_capture_groups = re.findall(r"([^::\s]+)[::]([^\s]+)","稿源:央视网 编辑:孙佩 发布时间:2017-09-15 15:31")
print(tuple_of_capture_groups)
# get keys of tuple array
keys = list(map(lambda kv:kv[0],tuple_of_capture_groups))
print(keys)
# filter number
not_num = list(filter(lambda key:not key.isdigit(),keys))
print(not_num)