python - 错误是: PermissionError: [Errno 13] Permission denied: 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\IP.PY'
问题描述
这是我的代码:
import shutil
original = r'C:\Users\Руслан\Desktop\HACKPROG\IP.PY'
target = r'C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp'
shutil.move(original,target)
我收到以下错误:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\Руслан\Desktop\HACKPROG\IP.PY", line 24, in <module>
shutil.move(original,target)
File "C:\Users\Руслан\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 820, in move
copy_function(src, real_dst)
File "C:\Users\Руслан\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 435, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Users\Руслан\AppData\Local\Programs\Python\Python39\lib\shutil.py", line 264, in copyfile
with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\IP.PY'
解决方案
您似乎没有写入“启动”文件夹的权限。
您可以通过以管理员身份运行 Python 终端来解决此问题(右键单击 IDLE/cmd 并按以管理员身份运行)。
推荐阅读
- python - 如何在一个 if 函数中测试 3 个变量?
- javascript - 如何在我的类组件中检测在功能组件中单击了哪个输入值?
- android - 实现 SharedPreferencesBackupHelper 的正确方法是什么?
- c - C程序中的浮点输出不正确
- reactjs - 在 React 组件中呈现表格存在问题
- javascript - 将数据注入 HTML 标签
- ruby-on-rails - gem Devise中授权路由和授权控制器之间的区别
- sql-server - SQL Server 如何删除空格?
- python - 从 Jupyter Notebook 创建 BigQueryML 模型
- c++ - 如何将数组的每个n个元素组合成一个元素