希望这可以帮助 :from os.path import isfile, existsfilename = input('Enter file name : ')if(exists(filename) and isfile(filename)): with open(filename) as f: content = f.readlines() # Call your function here with content as argument and process it, content has all lines in the file as a list