过滤字数大于3的列表
def get_content_wordnumber(html): text =re.sub('[\s+\.\!\/_,$%^*(+\"\']+|[+——!,::。?、~@#¥%……&*()“”《》]','',html) text2 = re.sub('<[^>]*?>', '', text) words_number = len(text2) return words_number a1 = '<p>你好呀你好呀你好呀你好呀你好呀你好呀</p>' a2 ='你好呀你好呀' a3 ='你好呀你好呀你好呀你好呀' a4 ='你好呀你好呀你好呀你好呀你好呀你好呀你好呀你好呀' # print(get_content_wordnumber(a1)) w = [a1,a2,a3,a4] cs1 = filter(lambda x:get_content_wordnumber(x)>3,w) print(list(cs1))
I was excited to uncover this website. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you bookmarked to look at new things in your site.