Log files

# Log files 
LST = [] # used to hold the log 
F = Open ( ' 2019-8 ' , MODE = ' R & lt ' , encoding = ' UTF-. 8 ' ) # read file 
first = f.readline (). Strip () .split ( ' , ' ) # of the first line of the file attributes is converted into an iterative extracts attribute list, as the dictionary Keys 
for line in F: # for loop reads the log file 
    DIC} = { # Create dictionary finishing log 
    k = line.strip (). Split ( ' , ' ) # log files will be extracted into a list of easy to extract value 
    for i inRange (len (First)): # File attributes may be increased according to the needs of 
        DIC [First [I]] = K [I] # added to an empty dictionary log 
    lst.append (DIC) # in a large list 
Print (LST )

 

Guess you like

Origin www.cnblogs.com/li33232/p/11426353.html