首页 > 解决方案 > 更改特定路径中文件的“用户”

问题描述

import shutil

path = input("Absolute path of the file and folder  ")


shutil.chown(path, user="Dude")

上面的程序应该已经成功执行而不是 this ,它向我显示了这个错误:

Absolute path of the file and folder  E:\SQL\Sqlemployee.py
Traceback (most recent call last):

  File "<ipython-input-2-b801c061f956>", line 4, in <module>
    shutil.chown(path, user="Dude")

  File "C:\Users\HP\Anaconda3\lib\shutil.py", line 1053, in chown
    raise LookupError("no such user: {!r}".format(user))

LookupError: no such user: 'Dude' 

已经有四个用户:Administrator、HP、Guest、Dude

标签: pythonshutil

解决方案


看起来您正在 Windows 命令提示符下运行代码。

shutil.chown仅在机器上可用。Unix


推荐阅读