Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
xlwt错误消息IOError:[Errno 13]权限被拒绝:';python_spreadsheet.xls';_Python_Python 2.7_Xlwt - Fatal编程技术网

xlwt错误消息IOError:[Errno 13]权限被拒绝:';python_spreadsheet.xls';

xlwt错误消息IOError:[Errno 13]权限被拒绝:';python_spreadsheet.xls';,python,python-2.7,xlwt,Python,Python 2.7,Xlwt,有人知道我为什么会犯这个错误吗?我只是从软件包的演示网站上复制了这段代码,我得到了这个错误 IOError:[Errno 13]权限被拒绝:“python_spreadsheet.xls”很可能,您没有在该特定文件夹中写入文件的权限。检查您是否有在该特定文件夹中写入的权限。 此外,定义文件的绝对路径可能会有所帮助。在Windows上,如果文件在Excel中打开,则会出现该错误 在Linux上,如果您没有写入输出目录或文件的权限,则会出现该错误。尝试以下解决方案: import xlwt boo

有人知道我为什么会犯这个错误吗?我只是从软件包的演示网站上复制了这段代码,我得到了这个错误


IOError:[Errno 13]权限被拒绝:“python_spreadsheet.xls”

很可能,您没有在该特定文件夹中写入文件的权限。检查您是否有在该特定文件夹中写入的权限。

此外,定义文件的绝对路径可能会有所帮助。

在Windows上,如果文件在Excel中打开,则会出现该错误

在Linux上,如果您没有写入输出目录或文件的权限,则会出现该错误。

尝试以下解决方案:

import xlwt

book = xlwt.Workbook(encoding="utf-8")
sheet1 = book.add_sheet("Python Sheet 1") 
sheet2 = book.add_sheet("Python Sheet 2") 
sheet3 = book.add_sheet("Python Sheet 3")
sheet1.write(0, 0, "This is the First Cell of the First Sheet") 
sheet2.write(0, 0, "This is the First Cell of the Second Sheet") 
sheet3.write(0, 0, "This is the First Cell of the Third Sheet") 
sheet2.write(1, 10, "This is written to the Second Sheet") 
sheet3.write(0, 2, "This is part of a list of information in the Third Sheet") 
sheet3.write(1, 2, "This is part of a list of information in the Third Sheet") 

book.save("python_spreadsheet.xls")

您没有在该文件夹中写入文件的权限。尝试在
book.save()
中指定您有写入权限的路径。或者检查文件是否已打开。您的答案非常有用:D
import xlwt 
wb = xlwt.Workbook('Database1.xls')
ws = wb.add_sheet('Sheet1') 
ws.write(9, 0, 11)
ws.write(9, 1, 'iii')
ws.write(9, 2, 387653)
wb.save('Database1.xls')