python-读取txt文件每行数据的第一个

利用split进行分割

f=open("output.txt","r", encoding = 'utf-8',errors='ignore')
for line in f:
    print(line.split(' ')[0])

 原文件:

 效果:

猜你喜欢

转载自www.cnblogs.com/1061321925wu/p/12296438.html