python 读取 execl表格
python 读取 表格
- pip2 install xlrd
- 获取sheet, data.sheets()[1]
- 获取总行 range(excel.nrows)
- 获取行1的表数据 excel.cell_value(rown, 1)
#!/usr/bin/env python3
import xlrd
data = xlrd.open_workbook(r'/home/han/zynq/zynq_pro2023/petalinux_test/doc/发射天线幅相表9330_9370_9410_9450_9490.xls')
print(data.sheets()[0])
print(data.sheets()[1])
print(data.sheets()[2])
print(data.sheets()[3])
print(data.sheets()[4])
#创建一个空列表,存储Excel的数据
tables = []
#将excel表格内容导入到tables列表中
def import_excel(excel):
for cnt in range(0,19):
if(cnt != 0):
print("\n,{", end="")
else:
print(" {", end="")
for rown in range(excel.nrows):
if(rown != 64):
print(excel.cell_value(rown,cnt + 1), end=",")
else:
print(excel.cell_value(rown,cnt + 1), end="}")
print()
if __name__ == '__main__':
#将excel表格的内容导入到列表中
import_excel(data.sheets()[1])
# import_excel(data.sheets()[2])
# import_excel(data.sheets()[3])
# import_excel(data.sheets()[4])
本文来自博客园踩坑狭,作者:韩若明瞳,转载请注明原文链接:https://www.cnblogs.com/han-guang-xue/p/17075016.html