Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #以下方法可计算字符串中元音字母(‘a’, ‘e’, ‘i’, ‘o’, ‘u’)的数目。
  2.  
  3. import re
  4. def count_vowels(str):
  5. return len(len(re.findall(r [aeiou] , str, re.IGNORECASE)))
  6. count_vowels( foobar ) # 3
  7. count_vowels( gym ) # 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement