1.在python中excel的简单读写操作,推荐使用xlrd(特别是读操作) 
2.到http://pypi.python.org/pypi/xlrd 去下载 xlrd库; 
3.工程代码如下:
复制代码 代码如下:
 import xlrd 
 def open_excel(fileName="simple.xls"): 
try:
 fileHandler = xlrd.open_workbook(fileName) 
 return fileHandler 
 except Exception, e: 
 print str(e) 
 def scan_excel(sheet_name1=u'Sheet1'): 
 handler = open_excel() 
 page = handler.sheet_by_name(sheet_name1) 
 return page 
 def trim_cols(index=0): 
 page = scan_excel() 
 col1 = page.col_values(index) 
 col2 = [] 
 for item in col1: 
 if item not in col2: 
col2.append(item)
 print col1 
 print col2 
 def main(): 
trim_cols()
 if __name__ == "__main__": 
main()
打印结果:
[1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0] 
[1.0, 2.0, 3.0, 4.0] 
 python中查找excel某一列的重复数据 剔除之后打印
2021-05-22 21:21:34声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。 如涉及版权问题,请提交至online#300.cn邮箱联系删除。
			
			
			
			
			
			
			
			
			
            
            
            
            
            
            
			
			
			
			
			
            
            
            
            
            
            
			
			
			
			
			
            
            
            
            
            
            


        

      热门文章
    