Ich habe vergessen, wie oft ich die Datei geöffnet, aber ich brauche sie zu schließen Ich habe die txt.close und txt_again.close, nachdem ich es mindestens 2 mal Geschlossene Dateien schließen?
geöffnetIch folge Zed A. Shaw Python Das Lernen Hard Way
#imports argv library from system package
from sys import argv
#sets Variable name/how you will access it
script, filename = argv
#opens the given file from the terminal
txt = open(filename)
#prints out the file name that was given in the terminal
print "Here's your file %r:" % filename
#prints out the text from the given file
print txt.read()
txt.close()
#prefered method
#you input which file you want to open and read
print "Type the filename again:"
#gets the name of the file from the user
file_again = raw_input("> ")
#opens the file given by the user
txt_again = open(file_again)
#prints the file given by the user
print txt_again.read()
txt_again.close()