#!/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(">>>> ", lines) #print("dir: ", lines[0][0:lines[0].rindex('/')]) #print("file: ", lines[0][lines[0].rindex('/')+1:]) d = {} i = int(0) for line in lines: parts = line.split('='); #print("%d: " % (i), parts) if len(parts) == 2: d[parts[0]] = parts[1] i += int(1) print("...", d) # begin gracefully # if __name__ == "__main__": main(sys.argv[0:]) # # end of file