python读取excel里面的某一列

作者: 萝卜枣 | 来源:发表于2021-09-30 11:55 被阅读0次

读取excel里面的某一列元素,并把它放在一个列表里面

import xlrd
id = []
worksheet = xlrd.open_workbook('./xlsx/item_base.xlsx')
sheet_names = worksheet.sheet_names()
#返回sheet的name ['structure', 'data', 'Sheet1', '备注', '命运卡', '地图(废弃)']
print(sheet_names)
# 取第二个sheet页data
rsheet = worksheet.sheet_by_index(1)
# row表示行
for row in rsheet.get_rows():
# 获取该行的第一列
id_column = row[0]
id_value = id_column.value
id.append(id_value)
print(id)

相关文章

网友评论

    本文标题:python读取excel里面的某一列

    本文链接:https://www.haomeiwen.com/subject/amsogltx.html