#从500彩票网站下载双色球历史数据,网页另存为01.txt data = [] file = open(‘01.txt‘) for line in file: line = line.lstrip() line = line.strip(‘\n‘) line = line.split(‘ ‘)[0] if len(line)==19 or len(line)==20 or len(line)==21: data.append(line) newFile = open(‘彩票数据.txt‘,‘w‘) for i in data: newFile.write(i) newFile.write(‘\n‘) newFile.close() ##for k in data: ## print(‘20%s%s: %s %s %s %s %s %s--%s‘%\ ## (k[0:2],k[2:5],k[5:7],k[7:9],k[9:11],k[11:13],k[13:15],k[15:17],k[17:19]))
原文:http://www.cnblogs.com/wumac/p/5958065.html