我試圖讓下面的代碼工作,它應該從用戶輸入的文本字符串中刪除元音。str.replace問題
def isVowel(text):
if text in ("a", "e", "i", "o", "u", "A", "E", "I", "O", "U"):
return True
def withoutVowels(text):
for char in text:
if(isVowel == True):
text = text.replace(char, "")
return text
isVowel函數工作正常,但它似乎沒有正確評估時,我使用它,爲什麼?
什麼是當它不能正常工作? – Xymostech 2013-03-17 01:25:25
注意:'''''''''''''''''''' without_vowles = re.sub('[aeiou]','',text,flags = re.IGNORECASE)'或're.sub('[aeiouAEIOU]','',text)'。 – EOL 2013-03-17 01:38:32