Python 3.5を使用して、ファイルを処理して別のファイルに出力を書き込むコードを作成しました。以下は関連するコードです。python 3.5スクリーンへの印刷出力なし
with open('2016_01_22_Investor_Companies_stops.txt','r') as stops_Investor_Companies:
stops_Investor_Companies = stops_Investor_Companies.read()
stops_Investor_Companies = nltk.word_tokenize(stops_Investor_Companies)
stops_Investor_Companies= [w.lower() for w in stops_Investor_Companies]
stops_Investor_Companies = str(stops_Investor_Companies)
outfile = open ('stops_Investor_Companies_cln.txt', 'w')
outfile.write(stops_Investor_Companies)
print ('1. Investor Companies')
print (' ')
with open('stops_Investor_Companies_cln.txt','r') as fin:
print(fin.read())
print (' ')
結果が画面にテキスト1. Investor Companies
版画ということですが、ファイルstops_Investor_Companies_cln.txt
が画面に印刷されません。
ただし、同じコードスニペットを別のスクリプトとして使用して、stops_Investor_Companies_cln.txt
というファイルを画面に印刷できます。
with open('stops_Investor_Companies_cln.txt','r') as fin:
print(fin.read())