涉及到處理excel文件中日期格式數據
這里自己整理下
兩種方法 代碼如下:
1 @classmethod 2 def get_time(cls, table, nrows): 3 testtime = [] 4 for i in range(1, nrows): 5 # data = xlrd.xldate.xldate_as_datetime(table.cell(i, 6).value, 1) 6 # 日期格式轉化成datetime對象 7 data = xlrd.xldate_as_tuple(table.cell(i, 6).value, 0) 8 # 日期格式轉化成元組 9 testtime.append(data.__str__()) 10 # 元組轉換成字符串 11 print testtime