fanjp666888
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)

分类:

技术点:

相关文章:

  • 2022-03-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2021-09-25
  • 2021-12-13
  • 2022-12-23
猜你喜欢
  • 2021-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-03-03
  • 2022-12-23
  • 2021-12-03
相关资源
相似解决方案