Python Forum

Full Version: iam getting problem that permission denied to open the file andprocess whileexecution
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import os,sys
sr=os.open("srinivas.txt",os.O_RDWR|os.O_CREAT)
line="this is test"
b=str.encode(line)
os.write(sr,b)
os.close(sr)
print("closed the function successfully")
Why are you using os at all?

Just use open for opening a file, and "w" for the access type (instead of os constants).