擅长:python、mysql、java
<blockquote>
<p>I have an array (list) of words. I want to loop though them and check if each one is in the English dictionary. If it is I want to increase a variable by 1.</p>
</blockquote>
<p>如果我没听错,你可以这样做:</p>
<pre><code>wordlist = ["foo", "bar", .....]
dictionary = …
words_in_dictionary = len([word for word in wordlist if word in dictionary])
</code></pre>
<blockquote>
<p>This is all very simple apart from the 'getting Python to read a dictionary' which I'm not sure about. I have found a .txt dictionary which I could use but the words are in there with definitions making it impossible to pick out the actual words.</p>
</blockquote>
<p>{cd2}你可以从unix中获得更好的单词。如果你把那本字典的一部分贴出来,我可以帮你。在</p>