有人可以解释代码它是如何工作的:我不熟悉while循环
line = file.readline()
L1=[]
while line != '' and line != '\n':
line = line[:-1].split()
L1.append(line)
line = file.readline()
return L1
我可以用for循环来做吗?是吗:
for line in file.readline():
if line !='' and line !='\n':
line = line[:-1].split()
L1.append(line)
return L1