#!/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 f: # i = int(0) # for l in f: # line = l.rstrip('\n') # print("1st method %d): %s (%d %d)" % # (i, line, len(line), len(line.strip()))) # if (len(line.strip()) != 0) and (line[0] != '#'): # print("1st method(%d): %s" % (i, line)) # i += int(1) # f.close() # second method # # for line in open(sys.argv[1],'r').readlines(): # print("2nd method: ", line) # 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