本帖最后由 double07 于 2021-10-22 15:28 编辑
[Python] 纯文本查看 复制代码 f=open('子链接.txt','r')
sourceInLine=f.readlines()
dataset=[]
for line in sourceInLine:
temp1 = line.split(',')
dataset.append(temp1)
print(len(dataset))
上面代码读出来的长度只有1,实际txt中长度应该为10
txt内容:
[Python] 纯文本查看 复制代码 'https://cq.ke.com//ershoufang/beibinlu/pg1p1/', 'https://cq.ke.com//ershoufang/beibinlu/pg1p2/', 'https://cq.ke.com//ershoufang/beibinlu/pg1p3/', 'https://cq.ke.com//ershoufang/beibinlu/pg2p3/', 'https://cq.ke.com//ershoufang/beibinlu/pg3p3/', 'https://cq.ke.com//ershoufang/beibinlu/pg1p4/', 'https://cq.ke.com//ershoufang/beibinlu/pg2p4/', 'https://cq.ke.com//ershoufang/beibinlu/pg3p4/', 'https://cq.ke.com//ershoufang/beibinlu/pg4p4/', 'https://cq.ke.com//ershoufang/beibinlu/pg1p5/' |