python - 如果我运行 .exe,则无法写入文件
问题描述
我正在编写一个简短的程序,我想将一个充满街道名称的数组写入 .txt 文件。Everyting 工作正常,但如果我使用 pyinstaller 将 python 代码转换为 .exe,我将无法再写入新的 .txt 文件。为什么会这样?
with open(f"C:\\Users\\auser\\Desktop\\tset\\{txtname}.txt", "a") as txt_file:
for line in new_addresses:
txt_file.write(line + "\n")
txt_file.close()
这就是我创建.exe的方式:
pyinstaller --onefile street.py
回溯(最后一次调用):文件“streets.py”,第 65 行,在 PermissionError:[Errno 13] 权限被拒绝:'C:\Users\auser\Desktop\tset\test.txt' [7048] 无法执行脚本重写字
解决方案
我现在开始工作了。我的防病毒程序由于某种原因阻止了执行。
推荐阅读
- python - 从现有数据框中添加新列以使每个 Id/Day 有一行
- prolog - Prolog 如何得出 3 < 2 之类的无意义结果?
- laravel - localhost 上的 Nuxt serverInit axios 获取 ENOTFOUND
- javascript - 使用 else if 语句更改背景颜色 - JQuery
- java - Java反汇编包含组件中方法头的字符串
- python - 如何正确绑定未存储在变量中的 wx.MenuItems
- javascript - 不能在 querySelector 上使用 forEach
- r - 如何在 R 中仅识别由“-”联合的单词?
- kubernetes - 如何将 fsGroup 设置为命名空间中的所有 pod
- vue.js - 如何将数组对象参数从 vue 网站传递给 google appscript 以设置 google 电子表格列值