【问题标题】:Permissions Error when trying to run a script in python尝试在python中运行脚本时出现权限错误
【发布时间】:2021-06-09 10:24:30
【问题描述】:

我正在尝试在 python 中运行脚本,但出现此错误:

PermissionError: [Errno 13] Permission denied: 'E:\\Projects\\Abusive Comments Filter\\zest.txt'

main.py

import re
import tkinter as tk
import subprocess
import urllib.request
from inscriptis import get_text

import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
path1 = os.path.join(BASE_DIR,'Abusive-Comments-Filter-master/zest.txt')

# url = input("Enter URL\n")
url = "https://www.quora.com/What-are-all-the-bad-words-and-their-meanings"
html = urllib.request.urlopen(url).read().decode('utf-8')

text = get_text(html)
path = r'path1'
# path = ''
file = open(path, 'w')
file.write(text)
file.close()

请问我该如何解决这个问题。

【问题讨论】:

    标签: python python-3.x permissions file-permissions permission-denied


    【解决方案1】:

    如果文件zest.txt 在您的文本编辑器或任何其他程序中打开,请关闭它。

    【讨论】:

    • 请问是哪个文件。
    • 您尝试访问的文件,zest.txt
    • 该文件不存在
    • 您好,您能否详细说明一下,您是在尝试创建文件还是读取它,您能否发布您的代码
    • 哦,好吧,但是当您说“该文件不存在”时,您是什么意思,如果文件不存在,您将无法读取文件,并且您的 python 脚本无法打开该文件存在但已在另一个程序中打开。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-12
    • 2019-08-23
    相关资源
    最近更新 更多