Read data in excel using Python
python中要想处理excel,必须用到第三方模块xlrd,所以windows 我安装方法是cmd中命令:E:\ANZHUANG\Python\Scripts>easy_install xlrd (路径必须在python的scripts下和必须安装easy_install)
#coding=utf-8 import xlrd def print_xls(path): data=xlrd.open_workbook(path) #打开excel table=data.sheets()[1] #打开excel的第几个sheet nrows=table.nrows #捕获到有效数据的行数 books=[] for i in range(nrows): ss=table.row_values(i) #获取一行的所有值,每一列的值以列表项存在 #print ss for i in range(len(ss)): print ss[i] #输出一行中各个列的值 print '+++++++++++++++++++' if __name__=='__main__': print_xls('D:\\文档\\431547909921.xls')
excel内的内容格式如下:
197 10208014 黄钊 男 医学院 预防医学 经金学院 经济学类
198 10208006 宋马小薇 女 医学院 预防医学 医学院 临床医学
199 10207014 杨婵媛 女 医学院 制药工程 医学院 口腔医学
200 10207018 祖丽皮亚 女 医学院 制药工程 医学院 临床医学
201 10207029 周力波 男 医学院 制药工程 医学院 临床医学
输出结果:
199.0
10207014.0
杨婵媛
女
医学院
制药工程
医学院
口腔医学
+++++++++++++++++++
200.0
10207018
祖丽皮亚
女
医学院
制药工程
医学院
临床医学
+++++++++++++++++++
201.0
10207029
周力波
男
医学院
制药工程
医学院
临床医学
+++++++++++++++++++

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

Pylance type detection problem solution when using custom decorator In Python programming, decorator is a powerful tool that can be used to add rows...

About Pythonasyncio...

Using python in Linux terminal...

Loading pickle file in Python 3.6 environment error: ModuleNotFoundError:Nomodulenamed...

Compatibility issues between Python asynchronous libraries In Python, asynchronous programming has become the process of high concurrency and I/O...

Error loading Pickle file in Python 3.6 environment: ModuleNotFoundError:Nomodulenamed...

The problem and solution of the child process continuing to run when using signals to kill the parent process. In Python programming, after killing the parent process through signals, the child process still...
