Commit 4caef5eb by 大雄

山羊拉丁文

parent bbc8b132
class Togoatlatin:
vowel = ['a', 'e', 'i', 'o', 'u'] # 此处定义vowel,在function中访问则需要vowel = self.vowel
def function(self, str):
vowel = self.vowel
# self.vowel = vowel
string = str.split()
for i in range(len(string)):
if string[i][0].lower() in vowel:
string[i] = string[i] + 'ma' + 'a'*(i+1)
else:
string[i] = string[i][1:] + string[i][0] + 'ma' + 'a'*(i+1)
return " ".join(string).lstrip(' ')
# vowel = ['a', 'e', 'i', 'o', 'u']
str1 = 'I speak Goat Latin'
goatlatin = Togoatlatin()
print(goatlatin.function(str1))
def my_print():
print("模块中的函数被调用")
class ImportClass:
def my_import_class_print(self):
print("ImportClass类中的方法被调用")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment