반응형
Openpyxl 및 python3.5를 사용하여 아래 첨자를 사용하여 Excel 워크 시트에서 첫 번째 행을 가져 오려고했지만 오류가 발생했습니다.
# after getting filename
# after loading worksheet
# to get the first row of the worksheet
first_row = worksheet.rows[0]
# I get
Traceback (most recent call last):
File "<pyshell#54>", line 1, in <module>
first_row = phc_th_sheet.rows[1]
TypeError: 'generator' object is not subscriptable
첫 번째 행을 얻는 것과 관련하여 나는 또한 시도했습니다 first_row = worksheet.(row=1) # and first_row = workstation.rows [: 1]
작동하지 않았습니다. 제안 사항이 있거나 openpyxl에서 사용할 수없는 기능입니까?
해결 방법
마침내 문서에서 답을 찾았습니다.
first_row = worksheet[1]
# worksheet[row_index_from_1]
이것은 나를 위해 일했습니다.
참조 페이지 https://stackoverflow.com/questions/40561670
반응형
'파이썬' 카테고리의 다른 글
파이썬 Python source code collection (0) | 2020.10.26 |
---|---|
파이썬 Python 3에서 URL 인코딩하는 방법은 무엇입니까? (0) | 2020.10.26 |
파이썬 matplotlib 막대 차트 : 공백 막대 (0) | 2020.10.26 |
파이썬 오류 발생-AttributeError : subprocess.run ([ "ls", "-l"])을 실행하는 동안 'module'개체에 'run'속성이 없습니다. (0) | 2020.10.26 |
파이썬 TypeError : 'int'개체는 구독 할 수 없습니다. (0) | 2020.10.26 |
댓글