我不斷收到錯誤INIT服用多個參數超過了
INIT()中定義的需要2的位置參數,但4分別給予
每當我運行下面的代碼。我用google搜索了這個問題,但它似乎像大多數人遇到這個錯誤,所以當他們嘗試傳遞一個對象時。我只是想傳遞一個字符串。有人可以幫我嗎?
class pigLatin_class(object):
def __init__(self,sentence):
self.sentence=sentence
def pigLatinConverter(sentence):
VOWELS=["a","e","i","o","u"]
sentence=sentence.split()
Pigword=""
for word in sentence:
if VOWELS[0] or VOWELS[1] or VOWELS[2] or VOWELS[3] or VOWELS[4] not in word:
Pigword+=word[1:] + word[0] + "way" + " "
elif word[0] in VOWELS:
Pigword+=word + "hay" + " "
else:
for i in range(len(word)):
if word[i] in VOWELS:
Pigword+=word[i:] + word[0:i] + "ay" + " "
break
return Pigword
p=pigLatin_class("ataruk esteban")
print(p)
UPDATE: 修正問題,多虧了評論。現在,我得到
<__main__.pigLatin_class object at 0x7f...>
運行給定的代碼都在Python 2和Python 3裏不給我一個錯誤;我只是在'0x7f500d9bce48'處得到'<__ main __。pigLatin_class對象''。這是你的所有代碼嗎?您需要向我們展示足夠的信息,以便我們可以重現問題。 – jwodder
這就是所有的代碼,當我在命令提示符下運行它時,我也可以得到它,但是spyder IDE給我提供了位置錯誤 – Doe22
無法在QPython3上重現。 – Carcigenicate