これがコードです
sys.path.append( "../tools/" )
from parse_out_email_text import parseOutText #(its just another .py file that has a function I wrote)
from_sara = open("from_sara.txt", "r")
from_chris = open("from_chris.txt", "r")
from_data = []
word_data = []
temp_counter = 0
for name, from_person in [("sara", from_sara), ("chris", from_chris)]:
for path in from_person:
### only look at first 200 emails when developing
### once everything is working, remove this line to run over full dataset
temp_counter += 1
if temp_counter < 200:
path = os.path.join('..', path[:-1]) #(THIS IS THE PART I CAN'T GET MY HEAD AROUND)
print path
email = open(path, "r")
email.close()
print "emails processed"
from_sara.close()
from_chris.close()
これを実行すると、次のようなエラーが表示されます。
Traceback (most recent call last):
..\maildir/bailey-s/deleted_items/101.
File "C:/Users/AmitSingh/Desktop/Data/Udacity/Naya_attempt/vectorize_text.py", line 47, in <module>
email = open(path, "r")
IOError: [Errno 2] No such file or directory: '..\\maildir/bailey-s/deleted_items/101.'
私のラップトップにはこの """'..\maildir/bailey-s/deleted_items/101.'""" ディレクトリ パスすらありません。コード内の '..' を置き換えてパスを変更しようとしましたすべてのファイルを保持するフォルダーへの実際のパス名によって、何も変更されません。
path = os.path.join('..', path[:-1])
このコードは、機械学習に関するオンライン コースの一部であり、この時点で 3 時間も立ち往生しています。どんな助けでも本当に感謝しています。
(PS これは宿題の質問ではなく、これに付けられた成績はありません。無料のオンライン コースです)