[英]Error with copy() function in reading excel files using python
I am working on a python prtogram that reads an excel file and based on the information in that file, writes data in the same file我正在研究一个 python 程序,它读取一个 excel 文件,并根据该文件中的信息,将数据写入同一个文件
This is my code:这是我的代码:
import xlrd
import xlwt
from xlutils import copy
location = "C:\\Users\\adarsh\\Desktop\\Python\\Other\\Blah.xls"
readbook = xlrd.open_workbook(location)
workbook = xlutils.copy(readbook)
sheet = workbook.get_sheet(0)
I get this error when I run my code:运行代码时出现此错误:
workbook = xlutils.copy(readbook)
AttributeError: module 'xlutils' has no attribute 'copy'
There is an error saying that there is no attribute copy
even though online tutorials use that feature I don't know how to fix this有一个错误说没有属性
copy
,即使在线教程使用了该功能我不知道如何解决这个问题
looks like you haven't imported the right function from the right place.看起来您没有从正确的位置导入正确的 function。 Try this:
尝试这个:
from xlutils.copy import copy
Then you can simply call:然后你可以简单地调用:
copy(readbook)
You imported copy specifically from the module so you shouldn't need the xlutils.copy() it should just be copy()您专门从模块导入了副本,因此您不需要 xlutils.copy() 它应该只是 copy()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.