from itertools import islice with open(“1.txt") as f: for a in islice(f,0,2): print(a) 转载于:https://www.cnblogs.com/yibeimingyue/p/10083859.html