安装后直接import openpyxl
然后就报
init() takes 1 positional argument but 4 were given咋回事啊,求解
from openpyxl import *
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl_init.py", line 6, in
from openpyxl.workbook import Workbook
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl\workbook_init.py", line 5, in
from .workbook import Workbook
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl\workbook\workbook.py", line 8, in
from openpyxl.worksheet.worksheet import Worksheet
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 30, in
from openpyxl.cell import Cell, MergedCell
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl\cell_init_.py", line 4, in
from .cell import Cell, WriteOnlyCell, MergedCell
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl\cell\cell.py", line 52, in
from openpyxl.styles.styleable import StyleableObject
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl\styles\styleable.py", line 11, in
from .builtins import styles
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\openpyxl\styles\builtins.py", line 1347, in
('Normal', NamedStyle.from_tree(fromstring(normal))),
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\defusedxml\common.py", line 113, in fromstring
parser = DefusedXMLParser(target=_TreeBuilder(),
File "C:\Users\lx1\AppData\Local\Programs\Python\Python39-32\lib\site-packages\defusedxml\ElementTree.py", line 68, in init
_XMLParser.init(self, html, target, encoding)
TypeError: init() takes 1 positional argument but 4 were given
应该ElementTree.py这个有问题,以前的没用的包,删了就好了
提示参数传的太多了,你是在python交互端引入的吗
安装方法对了吗?参考https://blog.csdn.net/a102111/article/details/46785745
报错翻译:
init只有一个位置参数,而给了4个
不可以_XMLParser.init(self, html, target, encoding)这样调用
init是构造函数,应该在实例化的同时传参