擅长:python、mysql、java
<p>我看到人们没有回答你问的问题。
当然,您调用的类有一个typo <code>Conjugason</code>而不是<code>Conjugaison</code>,但是它不会在这里产生任何错误。你知道吗</p>
<p>但是你在抱怨印刷顺序不对。
嗯,在Python中,标准字典是不排序的。你知道吗</p>
<p>我建议你用<a href="https://docs.python.org/2/library/collections.html#collections.OrderedDict" rel="nofollow noreferrer">OrderedDict</a>。这样,for循环将遵循创建字典时定义的顺序。你知道吗</p>
<pre><code>from collections import OrderedDict
class Conjugaison:
def Simple_Present(self):
self.group = OrderedDict([("Je", "e"), ("Tu", "es"), ("Il ou Elle", "e"),
("Nous", "ons"), ("Vous", "ez"),
("Ils ou Elles", 'ent')])
self.verb = str(input("Enter a verb here:"))
for keys in self.group:
print(keys,self.verb[:-2]+self.group(keys))
Em1 = Conjugaison()
Em1.Simple_Present()
</code></pre>
<p>附言:我是法国人,你可以加一个额外的逻辑。如果你的动词以元音开头,你需要用<code>J'</code>而不是<code>Je</code>。
对于单数第三人称,它应该是<code>Il ou Elle</code>,而不是<code>Il ou Elles</code>。
这里还不需要类,你可以在类之外调用你的函数。你知道吗</p>