尝试在 python 中运行脚本时出现权限错误

时间:2021-03-11 12:11:25

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

我正在尝试在 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()

我该如何解决这个问题。

1 个答案:

答案 0 :(得分:1)

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

相关问题