Install a Dictionary Module in Python

696 views python
2

I want to use all the word in an existing specific Dictionary and create a md5 hash out of it. How will I import a dictionary? What module shall I install?

answered question

1 Answer

0

Try this with any text file you like..

import hashlib
dict_fn = '/usr/share/dict/american-english'
with open(dict_fn) as f:
    text = f.read()
text = text.encode('utf-8')
m = hashlib.md5()
m.update(text)
print(m.hexdigest())

This will give your the same results as md5sum /usr/share/dict/american-english

Note that the dictionary I reference is on Ubuntu and so is the md5sum command line program.

posted this

Have an answer?

JD

Please login first before posting an answer.