print(min(len(g.strip()) for g in open("haha","r",encoding="utf8"))) -------------------------------------------------------------------------------- with open("haha","r",encoding="utf8") as fw: c = [] for oi in fw: cds = len(oi.strip()) c.append(cds) print(c) print("最",max(c))