1

i hav confirmed that "apples.txt" do exist.what is wrong with my code?

   def Loadfile(fileName):
        myfile=open(fileName,'r')
        next(myfile)
        for line in myfile:
            linesplit=line.split()
            print line

    print Loadfile('apples.txt')

2 Answers2

3

The file probably isn't in your working directory. Either change your working directory to where apples.txt is located, or provide a full path to the file such as 'C:\\folder\\subfolder\\apples.txt'

Community
  • 1
  • 1
Cory Kramer
  • 114,268
  • 16
  • 167
  • 218
0
arq = open('C:\\python2.6\\projetos\\test\\list.txt', 'r')
texto = arq.readlines()
for linha in texto:
    print(linha)
arq.close()
BREI
  • 101
  • 2
  • 4