First, print the project path
import them PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) print "Project path is",PROJECT_ROOT
2. Open the file and read line by line
open()
def testopenFile(fileName): import them PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__)) fo = open(fileName) print "Project path is",PROJECT_ROOT print "The file name is", fo.name print "The number of lines in the file is: ", len(fo.readline()) for line in fo.readlines(): line = line.strip() print "data is: %s" %(line) fo.close()