程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Excel operation in Python

編輯:Python

python in excle operation

First of all, we need to use xlrd modular , stay dos Enter command in : pip install xlrd Install the module . In the use of xlrd When the module , First enter i mport xlrd sentence , Put it in python Import the module from the top of the file .

Start by opening excle file

Document variable name = xlrd. open_workbook (r ‘ excle File path ’) File path

Through cable Elicit Take the... To be operated Worksheet

Worksheet name = Document variable name . sh ee ts ( ) [ Cable lead ]

according to page Face name a take Worksheet

Document variable name . sh ee t _b y _n am e ( page Face name )( name District branch Big A lowercase letter )

a take page Number of lines of the face

a= work do page Variable .nrow s

  a take page Number of columns of the face

b = work do page Variable .ncol s

a take some Inside a line Rong , Cable lead from 0 open beginning

row = work Name the table .row_ va l u e s ( Cable lead )

a Take the inner of the whole column of the first column Rong

col = work Name the table .col_ va l u e s ( Cable lead )

a take some A column of , The first 0~4 That's ok ( No package contain The first 4 That's ok )

P r i n t ( work Name the table .col_ va l u e s ( 0 , 0 , 4 ) )

work Name the table .col_ va l u e s ( Leso lead , open beginning That's ok , junction beam That's ok )

a take some That's ok , some The value of the column

Variable = work Name the table .cell ( That's ok , Column ) . va l u e

work Name the table .cell ( Traveling rope lead , Leso lead ) . va l u e

P r i n t ( work Name the table .cell_ va l u e s ( 1 . 0) )

r a ndo m Random modular

r a ndo m Modular r a nd i n t ( ) Function to raw become Random Count , Every time you Time After execution, it returns No Same as The number of , The syntax of this function is : r a ndo m . r a nd i n t (a, b )

Function returns a number N, N by a To b Number between ( a>=N<= b) , package contain a and b

im por t r a ndo m # Import r a ndo m modular

Ra ndo m . r a nd i n t ( 10, 50 )

notes It means : r a ndo m You can't be direct visit Of , Import required r a ndo m modular

r a ndo m . c h o i ce ( Tuples / list / r a n g e () / character string )

From the given tuple / list / r a n g e () / In a string Pick a yuan at random plain

Ra ndo m . c h o i ce ( “ a bcde fg ” ) character string

Ra ndo m . c h o i ce ( [ “ Zhang San ” , “ Li Si ” , “ king Two ” ] ) Array

Ra ndo m . c h o i ce ( ( “ Zhang San ” , “ Li Si ” , “ king Two ” ) ) Tuples

A= r a ndo m . c h o i ce ( r a n g e ( 1, 10) ) 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved