现在,我有了我能想到的最简单的测试脚本,但根据XlsxWriter的说明,它无法正常工作:

import pandas as pd
import numpy as np
import xlsxwriter

writer = pd.ExcelWriter("Test.xlsx", engine = "xlsxwriter")


完整错误:
    追溯(最近一次通话):

  File "<ipython-input-310-9c7e424c6d39>", line 1, in <module>
    writer = pd.ExcelWriter("Test.xlsx", engine = "xlsxwriter")

  File "/Users/ernie/anaconda3/lib/python3.6/site-    packages/pandas/io/excel.py", line 1725, in __init__
    self.book = xlsxwriter.Workbook(path, **engine_kwargs)

  File "/Users/ernie/anaconda3/lib/python3.6/site-packages/xlsxwriter/workbook.py", line 68, in __init__
    super(Workbook, self).__init__()

TypeError: super(type, obj): obj must be an instance or subtype of type

最佳答案

显然,该错误与Spyder和Python运行所在的会话有关。我完全退出了会话,重新启动它,错误消失了。某种原因使其损坏,但非常奇怪。

关于python - 无法在Python中使用XlsxWriter定义输出文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52633245/

10-12 23:03