Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #以下方法可计算字符串中元音字母(‘a’, ‘e’, ‘i’, ‘o’, ‘u’)的数目。
- import re
- def count_vowels(str):
- return len(len(re.findall(r [aeiou] , str, re.IGNORECASE)))
- count_vowels( foobar ) # 3
- count_vowels( gym ) # 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement