이 글은 주로 python3+xlrd를 사용하여 Excel을 분석하는 예제를 소개합니다. 이제 특정 참조 값을 공유합니다.
예제는 다음과 같습니다. # -*- coding: utf-8 -*-
import xlrd
def open_excel(file = 'file.xls'):#打开要解析的Excel文件
try:
data = xlrd.open_workbook(file)
return data
except Exception as e:
print(e)
def excel_by_index(file = 'file.xls', colindex = 0, by_index = 0):#按表的索引读取
data = open_excel(file)#打开excel文件
tab = data.sheets()[by_index]#选择excel里面的Sheet
nrows = tab.nrows#行数
ncols = tab.ncols#列数
colName = tab.row_values(colindex)#第0行的值
list = []#创建一个空列表
for x in range(0, nrows):
row = tab.row_values(x)
if row:
app = {}#创建空字典
for y in range(0, ncols):
app [ colName[y] ] = row[y]
list.append(app)
return list
def read_excel(file = 'file.xls', by_index = 0):#直接读取excel表中的各个值
data = open_excel(file)#打开excel文件
tab = data.sheets()[by_index]#选择excel里面的Sheet
nrows = tab.nrows#行数
ncols = tab.ncols#列数
for x in range(0, nrows):
for y in range(0, ncols):
value = tab.cell(x,y).value
print(tab.cell(x, y).value)
def main():
# print('input the path of your file:')
# a = open_excel(r'D:\smt_ioe\untitled\analysis_excel\my.xls')
# print(a)
b = excel_by_index(r'D:\smt_ioe\untitled\analysis_excel\my.xls', 0, 2)
m = []
for i in range(b.__len__()):
c = b[i]
# a = c['name']
for x in c:
if x == 'date':
print(x)
print('meng')
read_excel(r'D:\smt_ioe\untitled\analysis_excel\my.xls',2)
if __name__ == '__main__':
main()
관련 권장 사항:
Python을 사용하여 win32 COM을 통해 Excel을 열고 Sheet
위 내용은 python3+xlrd를 사용하여 Excel을 구문 분석하는 예의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond

pythonisnotpurelynlogreted; itusesahybrideprophorfbyodecodecompilationandruntime -INGRETATION.1) pythoncompilessourcecodeintobytecode, thepythonVirtualMachine (pvm)

ToconcatenatelistsinpythonwithesameElements, 사용 : 1) OperatorTokeEpduplicates, 2) asettoremovedUplicates, or3) listComperensionForControlOverDuplicates, 각 methodHasDifferentPerferformanCeanDorderImpestications.

PythonisancerpretedLanguage, 비판적 요소를 제시하는 PytherfaceLockelimitationsIncriticalApplications.1) 해석 된 언어와 같은 thePeedBackandbackandrapidProtoTyping.2) CompilledlanguagesLikec/C transformt 해석

useforloopswhhenmerfiterationsiskNownInAdvance 및 WhileLoopSweHeniTesslationsDepoyConditionismet whilEroopsSuitsCenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTherInatismet, 유용한 광고 인 푸트 gorit


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

WebStorm Mac 버전
유용한 JavaScript 개발 도구

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구