2203_75305878 2023-01-16 11:07 采纳率: 100%
浏览 107
已结题

关于#python#的问题,python写入excel时报错

python写入到excel时报错,代码是按视频写的(视频链接:https://www.bilibili.com/video/BV1HY4y1874L/?spm_id_from=333.788),一运行就报错
代码:

print(df)
df.to_excel('d:/大数据分析/利润表.xlsx/')

报错:

Traceback (most recent call last):
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\io\excel\_base.py", line 1144, in __new__
    engine = config.get_option(f"io.excel.{ext}.writer", silent=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\_config\config.py", line 263, in __call__
    return self.__func__(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\_config\config.py", line 135, in _get_option
    key = _get_single_key(pat, silent)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\_config\config.py", line 121, in _get_single_key
    raise OptionError(f"No such keys(s): {repr(pat)}")
pandas._config.config.OptionError: No such keys(s): 'io.excel..writer'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Users\Xuan\PycharmProjects\pythonProject\task.py", line 92, in <module>
    df.to_excel('d:/大数据分析/利润表.xlsx/')
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\core\generic.py", line 2374, in to_excel
    formatter.write(
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\io\formats\excel.py", line 918, in write
    writer = ExcelWriter(  # type: ignore[abstract]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\io\excel\_base.py", line 1148, in __new__
    raise ValueError(f"No engine for filetype: '{ext}'") from err
ValueError: No engine for filetype: ''
  • 写回答

4条回答 默认 最新

  • cjh4312 2023-01-16 11:34
    关注

    df.to_excel('d:/大数据分析/利润表.xlsx/')去掉.xlsx/后面的/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 1月24日
  • 已采纳回答 1月16日
  • 创建了问题 1月16日

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动