# 第一种写法,一个列表内含有多个子列表 weak_pass = [] withopen('weak_passwds_v1.txt','r') as f: for line in f: weak_pass.append(list(line.strip('\n').split(','))) print(weak_pass)
#第二种写法,一个列表包含所有元素 a = [] withopen('weak_passwds_v1.txt','r') as g: res = g.readlines() for res2 in res: a.append(res2.strip('\n')) print(a)