File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ #encoding=utf8
2+
3+ from __future__ import print_function
4+ import xlrd
5+
6+ data = xlrd .open_workbook ('Latest.xlsx' )
7+ #table = data.sheets()[0] #通过索引获取工作表
8+ #table = data.sheet_by_index(0) #通过索引顺序获取
9+ table = data .sheet_by_name (u'Sheet1' ) #通过名称获取
10+ #获取整行和整列的值
11+ #table.row_values(i)
12+ #table.col_values(i)
13+
14+ #获取行数和列数
15+ nrows = table .nrows
16+ ncols = table .ncols
17+ list_dispose = []
18+ for k , v in enumerate (table .col_values (0 )):
19+ if v .startswith ('@' ) or v .startswith (' @' ):
20+ list_dispose .append (v )
21+
22+ count = 0
23+ #f = open("domain1.txt", 'wb')
24+ for exactone in list_dispose :
25+ #f.write(exactone)
26+ print (exactone ,end = ' ' )
27+ count += 1
28+ if (count % 5 ) == 0 :
29+ print (end = '\n ' )
30+
31+ #for i in list_dispose:
32+ # print(i, end=' ')
33+ # count += 1
34+ # if(count%5==0)
35+ # print(end='\n')
36+ # print("", file = f)
37+
38+ #可以在命令行中用如下命令来将打印结果导入到textfile.txt
39+ #python myawesomescript.py >> textfile.txt
40+
41+ print (ncols )
42+ print (nrows )
You can’t perform that action at this time.
0 commit comments