pandas模块的使用中发生的错误:AttributeError: module ‘pandas‘ has no attribute ‘read

您所在的位置:网站首页 myrobot怎么读 pandas模块的使用中发生的错误:AttributeError: module ‘pandas‘ has no attribute ‘read

pandas模块的使用中发生的错误:AttributeError: module ‘pandas‘ has no attribute ‘read

2023-07-30 02:39| 来源: 网络整理| 查看: 265

代码是用于读取excel文件并且进行拼接的,

import pandas as pd path = r"D:\tenlink\text.xlsx" file1 = pd.read_excel(path,sheet_name=0) file2 = pd.read_excel(path,sheet_name=1) file3 = pd.read_excel(path,sheet_name=2) print(pd.concat((file1,file2,file3)))

在运行之后发现报错:

Traceback (most recent call last): File "D:/python_code/自动化办公/pdf操作/excel拼接.py", line 12, in file1 = pd.read_excel(path,sheet_name=0) AttributeError: module 'pandas' has no attribute 'read_excel'

确认代码没有问题后,又查了一下同文件夹内,我不知什么时候新建了个名字叫pandas的python文件,真是苦恼。 之前也遇到过此类问题,现在在这里写一个记录,不要把名字定义成与import的包名字相同,在后面加个test什么的吧,或者加个1,2,3,比如pandas1.py



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3