hello communityof stackoverflow, my question is about python

to import the absolute path from my laptop I type:

import os 

print(os.getcwd())

he gives me the path no problem, but when I create a Document “ayoub.txt” in the path absolute, and I #call this document with:

 file = open("ayoub.txt")

# I get an error:
#Traceback (most recent enter code herecall last):
  #File "C:UsersHPPRO~1AppDataLocalTemptempCodeRunnerFile.python", line 4, in <module>
    f#ile = open("ayoub.txt")
#FileNotFoundError: [Errno 2] No such file or directory: 'ayoub.txt'
#PS C:UsersHP PRO>

Answer

ayoub.txt should be created or opened with file add mode or write mode. The open function uses the default reading mode. If the file does not exist, it gives an error.