Python 读取 XLS 文件第一列并存入字符串数组
可以使用'xlrd'库来读取xls文件。以下是一个示例代码,用于将xls文件的第一列数据存入字符串数组:
import xlrd
# 打开xls文件
workbook = xlrd.open_workbook('data.xls')
# 选择第一个Sheet
sheet = workbook.sheet_by_index(0)
# 获取第一列数据
column_values = sheet.col_values(0)
# 将数据存入字符串数组
string_array = [str(value) for value in column_values]
print(string_array)
请确保在运行代码之前已经安装了'xlrd'库。
原文地址: https://www.cveoy.top/t/topic/qrZ6 著作权归作者所有。请勿转载和采集!