python读取txt文件


with open("E:\machineLearning/Tianchi/CTCN_data/CTCN_data/CTCN_data/Activity1.3_train_rgb.txt", "r") as f:
    i=0
    for line in f.readlines():
        line = line.strip('\n')  #去掉列表中每一个元素的换行符
        a=line.split(' ')#按空格分隔
        print(a[0])

你可能感兴趣的:(python读取txt文件)