基本的に、その場しのぎのスーパーワードカウントを行いたいのですが、必要なことを行うためのリストではなく、ディレクトリパス(引数として渡される)からdictオブジェクトを作成する方法がわかりません。
辞書オブジェクトを作成したいのですが、電子メール モジュールを使用して、ファイル名であるキーの ASCII 値を電子メールまたはメッセージ オブジェクトにフォーマットしたいと考えています。次に、ペイロードを使用して本文を抽出し、そのように解析します。以下に例を示します。
mylist=os.listdir(sys.stdin)
for emails in mylist:
email_str = emails.open()
#uncertain if this will get all emails and their content or not
#all emails are supposed to have a unique identifier, they are essentially still just ascii
file_dict = {emails : email_str}
#file_dict = dict(zip(mylist, mylist))
for emails in file_dict[emails]:
msg = email.message_from_string(email_str)
body = msg.get_payload(decode=True)
#I'm not entirely sure how message objects and sub objects work, but I want the header to
#signature and I'm not sure about the type of emails as far as header style
#pretend I have a parsing method here that implements the word count and prints it as a dict:
body.parse(regex)
値を解析する以外にキーはまったく必要ないので、代わりに message_from_file を使用することを検討してください。