# !/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import pycontrol.pycontrol as pc
import time
import csv
import ssl
from datetime import date,datetime
import xlrd
def read_excel(a):
wb=xlrd.open_workbook(filename=a) #打开文件
print wb.sheet_names() ##获取所有sheet页名字
print type(wb.sheet_names())
for x in wb.sheet_names():
print type(x)
print x.encode('utf-8')
sheet1=wb.sheet_by_name(u'批量提交')
print sheet1.name,sheet1.ncols,sheet1.nrows
b=sheet1.nrows
list = [[] for i in range(b)]
for i in range(sheet1.nrows):
if i==0:
pass
else:
print sheet1.row(i)
print type(sheet1.row(i))
for j in xrange(len(sheet1.row(i))):
#print j
if j==7:
#print j
# print sheet1.row(i)[j].value
# print sheet1.row(i)[j].value
print xlrd.xldate_as_datetime(sheet1.row(i)[j].value,0)
list[i].append(xlrd.xldate_as_datetime(sheet1.row(i)[j].value,0))
#print sheet1.row(i)[j].value.ctype
#print date(sheet1.row(i)[j].value).strftime("%Y-%m-%d %H:%M:%S")
else:
print sheet1.row(i)[j].value
list[i].append(sheet1.row(i)[j].value)
return list
lista=read_excel('test.xlsx')
while [] in lista:
lista.remove([])
print lista