Verwenden von Python 3.5 Ich habe Code erstellt, um eine Datei zu verarbeiten und Ausgabe in eine andere Datei zu schreiben. Folgendes ist der relevante Code;Python 3.5 keine Druckausgabe zum Bildschirm
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 (' ')
Das Ergebnis ist, dass der Text 1. Investor Companies
druckt auf den Bildschirm, aber die Datei stops_Investor_Companies_cln.txt
nicht auf den Bildschirm ausgegeben wird.
Allerdings kann ich die Datei stops_Investor_Companies_cln.txt
auf den Bildschirm mit dem gleichen Code-Snippet als separates Skript drucken;
with open('stops_Investor_Companies_cln.txt','r') as fin:
print(fin.read())