python操作excel
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)
######################
QQ 3087438119