openpyxl 第二行等于第一行
时间: 2023-09-13 13:07:11 浏览: 82
要比较openpyxl库中的第一行和第二行的数据是否相等,你可以使用openpyxl库中的Worksheet对象的cell属性来获取每个单元格的值,然后进行比较。首先,你需要导入openpyxl库并加载Excel文件:
```python
import openpyxl
wb = openpyxl.load_workbook('test.xlsx')
ws = wb['Sheet1']
```
然后,你可以通过使用Worksheet对象的cell属性来获取每个单元格的值,并将它们存储在两个列表中,分别对应第一行和第二行的数据:
```python
first_row = []
second_row = []
for cell in ws<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [openpyxl追加行、指定位置插入行](https://blog.csdn.net/weixin_39984442/article/details/111065438)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [【曾贤志】openpyxl处理Excel数据 - 第2季 巩固篇](https://download.csdn.net/download/weixin_38590790/19946834)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [openpyxl 如何按行读取数据](https://blog.csdn.net/xue_11/article/details/120694358)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文