<分区> 分区>
我想使用以下代码通过 Python 在我的 Windows 主机文件中添加一行:
fh = open("C:\Windows\System32\drivers\etc\hello.txt", "w")
fh.write("new line")
fh.close()
但是我得到这个错误:
PermissionError: [Errno 13] 权限被拒绝:'C:\\Windows\\System32\\drivers\\etc\\hello.txt'
即使我的防病毒软件被禁用,它也不起作用。
我不知道如何在 Windows 机器上以管理员身份编写文件。
