首页 > 编程语言 >python 读取excel

python 读取excel

时间:2022-11-02 10:46:35浏览次数:41  
标签:读取 python excel baseinfo cell sheetname import day

练习

# coding: utf-8
"""
# @Time : 2022/10/25 17:47
# @Author : Gina Gao
# @File :
# @Software: PyCharm
# @Descript:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple xlwt
学习网址:https://baijiahao.baidu.com/s?id=1692102953555208325&wfr=spider&for=pc
学习网址:https://blog.csdn.net/qq_51292462/article/details/123163968
"""
import xlrd
import datetime
import  os
from base_info import  baseinfo

baseinfo=baseinfo() #实例化

path=r'C:\Users\EDY\Desktop\gina_test.xlsx'
sheetname = '小高天天乐'  # 添加sheetname
rd_excel=xlrd.open_workbook(path)
excel=rd_excel.sheet_by_name(sheetname) #等价 sn=rd_excel.sheets()[1]
#根据源码分析,cell()返回的是单元格的数据类型和单元格的值。cell_value()返回的只是单元格的值。
print(excel.nrows,excel.ncols,excel.cell_value(2,5),"我在这里",excel.cell(2,5))
day_number=excel.cell_value(2,5)

print(day_number,baseinfo.fomat_datetime(day_number))
col5 = excel.col_values(5) ## 返回某6列的元素列表
row2 = excel.row_values(2)  # 返回某一行的元素列表

print(row2)

 

标签:读取,python,excel,baseinfo,cell,sheetname,import,day
From: https://www.cnblogs.com/gina11/p/16850255.html

相关文章