帮我写python操作excel代码
时间: 2023-03-23 21:04:10 浏览: 133
好的,我可以为您提供一些关于Python操作Excel的代码。您可以使用openpyxl库来操作Excel文件。以下是一个简单的示例代码:
```python
import openpyxl
# 打开Excel文件
workbook = openpyxl.load_workbook('example.xlsx')
# 选择工作表
worksheet = workbook['Sheet1']
# 读取单元格的值
cell_value = worksheet['A1'].value
# 写入单元格的值
worksheet['A2'] = 'Hello, World!'
# 保存Excel文件
workbook.save('example.xlsx')
```
您可以根据您的需求修改代码,例如读取整个工作表或写入多个单元格的值。希望这可以帮助到您!
阅读全文
相关推荐














