擅长:python、mysql、java
<p>您可以尝试以下方法:</p>
<pre><code>Pokemon = {}
while True:
command = input("Command: ")
if "Capture" in command:
command = command.split(' ')
if not command[1] in Pokemon:
Pokemon[command[1]] = command[2]
else:
print("You are already training {}!".format(command[1]))
elif "Query" in command:
command = command.split(' ')
if command[1] not in Pokemon:
print("You have not captured " + command[1] + " yet.")
else:
print(command[1] + " is level " + Pokemon[command[1]] + ".")
else:
print("Unknown command!")
</code></pre>
<p>输出:</p>
<pre><code>Command: Capture Eevee 4
Command: Query Eevee
Eevee is level 4.
Command: Capture Eevee 6
You are already training Eevee!
Command:
</code></pre>