+ 2
Opening a file in python
f=open (file path with name,"r") cc=f.read() print(cc) file.close() how the path should be mentioned so that I can read the text file created in notepad++
5 odpowiedzi
+ 2
let suppose our file is in local disk D in folder name code and our file name is first.txt .Then how we specified the path.
f=open(r"D:\code\first.txt","r")
cc=f.read()
print(cc)
file.close()
+ 1
yeah if I create a file in same folder then it's ok I can open it with the file name only...but for files created in different folders I am not able to get how to mention right path..
+ 1
what is that 'r' just before 'open' u r mentioning in first line
+ 1
Manindar Singh:
Thankyou without that 'r' error was occuring 😁🙏
0
lets say this (this won't work for you, just an example)
path:
/home/yee/codes/filename.txt