1、a.log文件中包含以下
eddy|123|18
jay|456|20
2、 目标结构:
2.1、['eddy|123|18','jay|456|20']
2.2、[['eddy','123','18'],['jay','456','20']]
def li(f1):
new_li = []
with open('a.log',mode='r',encoding='utf-8') as f1:
data = f1.read()
data1 = data.split('
')
return data1
v = 'a.log'
print(li('a.log'))
2.1
def li(f1):
new_li = []
with open('a.log', mode='r', encoding='utf-8') as f1:
data = f1.read()
data1 = data.split('
')
for i in data1:
data2 = i.split('|')
new_li.append(data2)
return new_li
v = 'a.log'
print(li('a.log'))
2.2