#!/usr/bin/env python # !-*-coding:utf-8 -*- import xlrd, datetime, time import sys import xml.dom.minidom import os print sys.getdefaultencoding() reload(sys) # 就是这么坑爹,否则下面会报错 sys.setdefaultencoding('utf-8') # py默认是ascii。。要设成utf8 # excel中 数据格式如下: # UID 第四天 # 1579880025 10:00-13:30 # 1677982825 10:00-12:00 # 1704410718 10:00-12:00 # 83713892 10:00-12:00 # 1546551561 10:00-12:00 # 1298790776 10:00-12:00 def open_excel(file_path): try: data = xlrd.open_workbook(file) # xlrd 操作excel的外部库 return data except Exception, e: print str(e) bgntm = '2017-05-18_' def get_time_t(stime): stime = bgntm + stime + ':00' # return time.strptime(stime, '%Y-%m-%d %H:%M:%S') #将时间转成时间戳 return stime def excel_table_byindex(file_path, colnnameindex=0, by_index=0): data = open_excel(file_path) # 打开excel table = data.sheets()[by_index] nrows = table.nrow
python excel转成xml
最新推荐文章于 2024-05-26 14:01:01 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)