python操作excel
pip install openpyxl
写:
import openpyxl # Load the workbook workbook = openpyxl.load_workbook('path/to/file.xlsx') # Select the worksheet worksheet = workbook['Sheet1'] # Write data to the worksheet worksheet['A1'] = 'Hello, world!' # Save the workbook workbook.save('path/to/file.xlsx')
读:
import openpyxl # Load the workbook workbook = openpyxl.load_workbook('path/to/file.xlsx') # Select the worksheet worksheet = workbook['Sheet1'] # Read the data from the worksheet for row in worksheet.iter_rows(values_only=True): print(row)
######################
标签:openpyxl,python,worksheet,excel,file,path,workbook,操作 From: https://www.cnblogs.com/herd/p/17297766.html