如题。
This is initally generated by OpenAI and further polished by the auther.
chatGPT的出现大大降低了编程的门槛,估计这些社区的活动量会越来越低。在社区大量的低质量内容中寻找资源的效率远低于与大数据模型进行直接对话。这个账号好久不更新了,预计以后对于工具类代码的更新会越来越少。AI 不会取代人类,取代的是不善于使用AI的人。
pip install openpyxl
import openpyxl
# Load the Excel file
file_path = 'path_to_your_file.xlsx'
workbook = openpyxl.load_workbook(file_path)
# Select a specific sheet (replace 'Sheet1' with your sheet name)
sheet = workbook['Sheet1']
# Initialize a 2D matrix (list of lists) to store the data
matrix = []
# Iterate through rows and store each row as a list in the matrix
for row in sheet.iter_rows(values_only=True):
matrix.append(list(row))
# Close the workbook
workbook.close()
# Now 'matrix' contains the Excel data as a 2D matrix
for row in matrix:
print(row)