import os
# Open the file in write-only mode
g = os.open("d:\Coding\Python\OS module practise.txt", os.O_WRONLY)
os.write(g, b"Hi")
I ran this code and I am getting the following error
Traceback (most recent call last): File "d:\Coding\Python\Practice files\Practice\day 12\practice4.py", line 7, in os.write(g, b"HI") OSError: [Errno 9] Bad file descriptor
I don't understand what is the problem?
I tried adding "Hi" to the txt file but it threw an error.