由于权限问题,无法在python中提取tar文件

时间:2019-02-27 10:19:50

标签: python-3.x python-2.7 tarfile

我无法在python中提取tar文件。

这是用于提取Python中tar文件的代码库。

file_path = os.path.join(extracted_tar_files, file.strip('.tar'))
tf = tarfile.open(os.path.join(files_directory, file))
tf.extractall(file_path)
tf.close()

某些tar文件可以正常工作。某些tar文件出现以下错误。

  

*** PermissionError:[Errno 13]权限被拒绝:'\ home \ piercer \ etc.sudoers'

能在这里帮忙吗?谢谢!

1 个答案:

答案 0 :(得分:1)

该文件似乎属于其他人,您似乎没有读取权限。如预期的sudoers文件一样。您可以更改权限:

$ sudo -E chown $USER /home/piercer/etc.sudoers