-1
を使用して電子メールファイルを読み取ろうとする:私はフォルダディレクトリ内の電子メールファイルを読み込むしようとしているが、私はこのエラーを取得していパイソン
AttributeError: '_io.TextIOWrapper' object has no attribute 'message_from_file'
import os
import email
for dirName, subdirList, fileList in os.walk(directory):
print('Found directory: %s' % dirName)
for fname in fileList:
f = os.path.join(dirName, fname)
with open(f) as email:
msg = email.message_from_file(f)
print(msg['from'])
これは、ファイルがどのように見えるかです:
Message-ID: <[email protected]>
Date: Mon, 5 Nov 2001 07:08:06 -0800 (PST)
From: [email protected]
To: [email protected]
Subject: vol book spreadsheets
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-From: Chen, Hai </O=ENRON/OU=NA/CN=RECIPIENTS/CN=HCHEN2>
X-To: Arora, Harry </O=ENRON/OU=NA/CN=RECIPIENTS/CN=Harora>
X-cc:
X-bcc:
X-Folder: \Harry_Arora_Jan2002\Arora, Harry\Inbox
X-Origin: Arora-H
X-FileName: harora (Non-Privileged).pst
何を電子メールで読むのですか? – mrid
@gomb yea私は、更新されたOP – Batman