xlrd를 사용하여 엑셀 시트에서 열을 추출하여 목록으로 만드십시오.Python : 문자열 목록에서 문자열 부분을 제거하십시오.
from xlrd import open_workbook
book = xlrd.open_workbook("HEENT.xlsx").sheet_by_index(0)
med_name = []
for row in sheet.col(2):
med_name.append(row)
med_school = []
for row in sheet.col(3):
med_school.append(row)
print(med_school)
다음은 목록의 스 니펫입니다. med_school.
[text:'University of San Francisco',
text: 'Harvard University',
text:'Class of 2016, University of Maryland School of Medicine',
text:'Class of 2015, Johns Hopkins University School of Medicine',
text:'Class of 2014, Raymond and Ruth Perelman School of Medicine at the
University of Pennsylvania']
목록의 각 문자열에서 'text :'Class of 2014 '를 제거하고 싶습니다. 목록 이해력을 시도했지만 속성 오류가 있습니다. '셀'객체에는 '스트립'속성이 없습니다. 누구든지 학년도와 단어 "텍스트"가없는 의과 대학 이름을 가진 의과 대학 이름 목록을 만드는 방법을 알고 있습니까?
예제 목록 출력에 문제가 있습니다. 아마도''텍스트와 같은 추가 따옴표가있을 것입니다. ''of Class ... ' "'? 아마도 출력물을 여기에서 바로 복사하거나 붙여 넣기 * 할 수 있습니다. – jwd
** text 앞에 ** 큰 따옴표가없고 ** 각 행의 끝에 있습니까? – Prune
리스트 출력에 아무런 문제가 없습니다. 이것은 단순히'xlrd.Cell' 인스턴스가'__repr__'을 구현하는 방식입니다. – donkopotamus