Python权限错误:[Errno 13]尝试将txt保存到程序文件(x86)时权限被拒绝

2024-04-29 16:40:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道还有其他类似的问题,但都没有帮助。以下是完整代码:

    save_path = r'C:\Program Files (x86)\Mod Tool\Infractions\Kicks'
    name_of_file = whoisit
    completeName = os.path.join(save_path, name_of_file + ".txt")
    file1 = open(completeName, "w")
    file1.write("Username: " + whoisit + "  //  "+ whatisit + " // Reason: " + reason)
    file1.close()
    print("Infraction stored.")
    print("")
    print("/kick" + ":" + whoisit + ":" + reason)
    print("")
    start()

为了让您通过,save_path是我希望它保存在的文件夹(txt将保存在Kicks文件夹中)


Tags: ofpath代码nametxt文件夹saveprogram
1条回答
网友
1楼 · 发布于 2024-04-29 16:40:48

我认为你需要在windows中以管理员身份运行才能写入程序文件。 尝试以管理员身份运行。在

通常:右键单击->以管理员身份运行。在

相关问题 更多 >