I would like to add a line in my Windows hosts file via Python with this code:
fh = open("C:\Windows\System32\drivers\etc\hello.txt", "w")
fh.write("new line")
fh.close()
But I get this error:
PermissionError: [Errno 13] Permission denied: 'C:\\Windows\\System32\\drivers\\etc\\hello.txt'
It doesn't work even if my antivirus is disabled.
I don't know how to write a file as an administrator on a Windows machine.