标签:xls 请求 elf font return get for names sts
resp = My_Request_Get(xls_url) # My_Request_Get是我自己封装的请求函数,可修改为requests请求
f = open(‘%s.xls‘ % _dic[‘title‘], ‘wb‘)
f.write(resp.content)
f.close()
con_list = self.Read_Xls(u‘%s.xls‘ % _dic[‘title‘])
def Read_Xls(self, path):
try:
"""获取xls文件内容"""
import xlrd
con_list = [] # 存储xls每行数据的列表
file_path = path.encode(‘utf-8‘)
data = xlrd.open_workbook(file_path) # 读取xls
# print data.sheet_names()[0] # 获取sheet
table = data.sheet_by_name(data.sheet_names()[0])
nrows = table._dimnrows # 获取xls行数
for line in range(int(nrows)):
rowvalue = table.row_values(line)
con_list.append(rowvalue)
# for i in rowvalue:
# print i
return con_list
except Exception as e:
traceback.print_exc(e)
标签:xls 请求 elf font return get for names sts
原文地址:https://www.cnblogs.com/fanjp666888/p/9802172.html