filename = "somefile.txt" myfile = open(filename) lines = len(myfile.readlines()) print "There are %d lines in %s" % (lines, filename)
希望本文所述对大家的Python程序设计有所帮助。