#!/usr/bin/env python # import required modules: # note that the path to the module htkmfc must be included in the # PYTHONPATH environment variable. # import os import sys # main: this is the main function of this Python # def main(argv): # first method # #with open(sys.argv[1]) as fp: # i = int(0) # for l in fp: # line = l.rstrip('\n') # print("1st method %d): %s (%d)" % # (i, line, len(line))) # i += int(1) #fp.close() # second method # #print("second method: ...") #for l in open(sys.argv[1], 'r').readlines(): # line = l.rstrip('\n') # print("2nd method: ", line) #f.close() # third method # print("third method: ...") lines = [line.rstrip('\n') for line in open(sys.argv[1])] print("3rd method: ", lines) for line in lines: parts = line.split(); print("parts = %s" % parts) # begin gracefully # if __name__ == "__main__": main(sys.argv[0:]) # # end of file