擅长:python、mysql、java
<p>您可以使用字典来跟踪键和值。</p>
<p>例如。。。</p>
<pre><code>dictOfStuff = {} ##Make a Dictionary
x = "Buffalo" ##OR it can equal the input of something, up to you.
dictOfStuff[x] = 4 ##Get the dict spot that has the same key ("name") as what X is equal to. In this case "Buffalo". and set it to 4. Or you can set it to what ever you like
print(dictOfStuff[x]) ##print out the value of the spot in the dict that same key ("name") as the dictionary.
</code></pre>
<p>字典和现实生活中的字典很相似。你有一个词,你有一个定义。你可以查一下这个词并得到它的定义。在这个例子中,你有“水牛”这个词,它的定义是4。它可以与任何其他单词和定义一起工作。先把它们放进字典里。</p>