去掉元音字母
''' 去掉给定字符串中的元音字母 ''' #解法1 def disemvowel(string): rlt=[] for i in string: if i.lower() not in 'aoeiu': rlt.append(i) return ''.join(rlt) #解法2: def disemvowel2(string): return ''.join(i for i in string if i.lower() not in 'aoeiu') #解法3 def disemvowel3(s): for i in "aeiouAEIOU": s = s.replace(i,'') return s #解法4 def disemvowel4(s): return filter(lambda x:x not in 'aoeiuAOEIU',s) print(disemvowel3('calecongration')) print(disemvowel4('calecongration'))