cemaxiaoxifeng

统计元音字母

import re
\'\'\'
#统计单词元音字母数量
word = input(\'please enter your word:\')
pattern = re.compile(r\'[aeiou]\') #reg = r\'[aeiou]\' pattern = re.compile(reg)
the_letters = pattern.findall(word)
print(len(the_letters))
\'\'\'
#分类统计元音字母数量
word = input(\'please enter your word:\')
def caculate(word):
pattern1 = re.compile(r\'[aeiou]\')
pattern2 = re.compile(r\'[a]\')
pattern3 = re.compile(r\'[e]\')
pattern4 = re.compile(r\'[i]\')
pattern5 = re.compile(r\'[o]\')
pattern6 = re.compile(r\'[u]\')
the_letters_all = pattern1.findall(word)
the_letters_a = pattern2.findall(word)
the_letters_e = pattern3.findall(word)
the_letters_i = pattern4.findall(word)
the_letters_o = pattern5.findall(word)
the_letters_u = pattern6.findall(word)
the_all = print(\'元音字母总数:\',len(the_letters_all))
the_a = print(\'a:\',len(the_letters_a))
the_e = print(\'e:\',len(the_letters_e))
the_i = print(\'i:\',len(the_letters_i))
the_o = print(\'o:\',len(the_letters_o))
the_u = print(\'u:\',len(the_letters_u))
#return the_all,the_a,the_e,the_i,the_o,the_u
print(caculate(word))




posted on 2017-11-16 19:56  策马啸西风-听雪  阅读(169)  评论(0编辑  收藏  举报
 

分类:

技术点:

相关文章:

  • 2021-11-06
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
猜你喜欢
  • 2021-06-17
  • 2022-01-05
  • 2022-12-23
  • 2021-12-06
  • 2021-12-18
  • 2022-12-23
  • 2021-07-09
相关资源
相似解决方案