I am trying to create a file at the given path in my computer (Windows 7) but the file is not being created at given path. It is created virtually in compiler till the time code is being executed, but it is not being created on OS.
x = str(input("Please enter the file name: ")) x = 'C:\Users\Aakash\Documents\Aakash\Aakash College\Practical\MIT Paython\\'+x f = open('x','w') print 'Please choose your option:' print '1.Write' print '2.Read' choice = int(input('Enter the number: ')) while choice==1: text = input('Please enter the string: ') f.write(text) f.write('\n') print 'Please choose your option:' print '1.Write' print '2.Read' choice = int(input('Enter the number: ')) if choice==2: f.close() print f = open('x','r') text = f.readline() print text while text!='': text = f.readline() print text f.close()
I think that windows is not giving permission to create a file. So how to get that permission such that it will create a real file in the given location?
It works while I try the same piece of code with IDLE however when I try it in a new file (by creating Module) it doesn't work! (i.e Module runs properly without any error but doesn't create the real file)
Note: The file is ran from the Admins user account. And he has permission to access all the directories.