0

When I am trying call an function It says no file or directory exits. But the file and directory actually exits . I have folder called XML where I have couple xml files

123.xml
456.xml
678.xml

I am try calling the function

send(uui)

It gives me the error

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-52-c4dc9477b488> in <module>
----> 1 send(uui)

<ipython-input-51-1add266355d1> in send(uui)
     11 
     12         uui = uuid.uuid4()
---> 13         mydoc = open(file)
     14         xml = mydoc.read()
     15         print(file + '_ ' + str(uui))

FileNotFoundError: [Errno 2] No such file or directory: '123.xml'

What is wrong. How to fix this?

1 Answer 1

1

os.listdir() returns the name of the file in the directory, without the directory name. Add the directory name to the file name:

mydoc = open("XML" + os.sep + file)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.