0
I am opening a file but it shows file not exist even if it exists
Solve
11 Respuestas
+ 7
Please show us your code, that may help to find the issue. Also name the platform you are working on (Windows, Android, Apple, Linux) Thanks!
+ 5
The error occurs, because try: always need a valid except: block.
...
try:
print("done")
except Exception as e:
print(e)
+ 4
ALL IN ONE GYAN, i took your code as it is, and pasted it in a local IDE, and created the required txt files in the same directory. Both versions are running without any problem The codes are the same, except the for loop, but this has no influence on reading the files. If you try to run the codes in playground, both of them will fail, as the files do not exist.
+ 3
Who will tell the information about language. Use cmd or terminal to get its Path .
I think you would get it like that .
I use mobile so that I use pydroid3 for finding the path of file.
+ 3
Use appropriate tags for more read on :
https://www.sololearn.com/Discuss/333866/?ref=app
+ 3
So you are absolutely sure that the desired files are in the same directory as the python file and also have the correct name and you also have access rights to them?
0
"""I am using pydroid3"""
f=open("n1.txt")
print (f.read())
f.close()
g=open("n2.txt")
print (g.read())
g.close()
h=open("n3.txt")
print (h.read())
h.close()
i=open("n4.txt")
print (i.read())
i.close()
j=open("n5.txt")
print (j.read())
j.close()
"""This code doesn't shows me error but the next one shows file doesn't exist"""
n=int(input())
a=0
while(a!=n):
a=a+1
print("*"*a)
f=open("n1.txt")
print (f.read())
f.close()
g=open("n2.txt")
print (g.read())
g.close()
h=open("n3.txt")
print (h.read())
h.close()
i=open("n4.txt")
print (i.read())
i.close()
j=open("n5.txt")
print (j.read())
j.close()
"""This code shows no file file exists."""
0
But I am using pydroid3 it doesn't work on it
0
Yes
0
a=int(input())
if a==1:
print("Whose data you want to log in.")
b=input()
print("What data you want to log\n1.Diet\n2.Excersice")
c=int(input())
if c==1:
d=="d"
elif c==2:
d=="e"
try:
print("done")
Why this file is showing EOF error when using try.pls help
0
Problem is with 'try:' and the next line. If you cut that, the code is running fine.