In Python to work with Excel, you must use the third-party module XLRD, so the Windows I install method is cmd command: E:\anzhuang\python\scripts>easy_install xlrd (The path must be under Python's scripts and must be installed Easy_install)
#coding =utf-8import xlrddef Print_xls (path):d ata=xlrd.open_workbook (path) #打开exceltable =data.sheets () [1] # Opening the first sheetnrows=table.nrows of Excel #捕获到有效数据的行数books =[]for i in Range (nrows): Ss=table.row_values (i) # Gets all the values of a row, the value of each column exists as a list item #print ssfor i in range (len (ss)):p rint ss[i] #输出一行中各个列的值print ' +++++++++++++++++++ ' if __name_ _== ' __main__ ':p rint_xls (' d:\\ document \\431547909921.xls ')
The content format in Excel is as follows:
19710208014 Huang College of Preventive Medicine, School of Economics
19810208006 the clinical medicine of the School of Preventive Medicine, song Ma Xiaowei female Medical College
19910207014 Yang Yanyuan Medical College of Pharmacy, pharmaceutical engineering, stomatology
20010207018 Clinical Medicine of Pharmaceutical Engineering Medical College, Zuli
20,110,207,029 Zhou Li Bo Male Medical College Pharmaceutical Engineering Medical School clinical Medicine
Output Result:
199.0
10207014.0
Yang Yanyuan
Woman
Medical
Pharmaceutical Engineering
Medical
Oral medicine
+++++++++++++++++++
200.0
10207018
Zulpiye
Woman
Medical
Pharmaceutical Engineering
Medical
Clinical
+++++++++++++++++++
201.0
10207029
Zhou Lipo
Man
Medical
Pharmaceutical Engineering
Medical
Clinical
+++++++++++++++++++