85 lines
2.3 KiB
Python
85 lines
2.3 KiB
Python
"""
|
|
Author : XinYi Song
|
|
Time : 2021/11/4 9:27
|
|
Desc:
|
|
"""
|
|
import datetime
|
|
import os
|
|
import time
|
|
|
|
|
|
def file_store_path(time_stamp):
|
|
"""
|
|
:param time_stamp: 时间戳类型时间
|
|
:return:
|
|
"""
|
|
now = int(round(time_stamp * 1000))
|
|
t = time.localtime(now / 1000)
|
|
return os.path.join('E:/data/upload', str(t[0]), str(t[1]), str(t[2]))
|
|
|
|
|
|
def file_store_path_year(data_str_time, upload_path, conllection_code):
|
|
"""
|
|
目录到年
|
|
:param upload_path:
|
|
:param data_str_time: 字符串类型
|
|
:return:
|
|
"""
|
|
t = time.strptime(data_str_time, '%Y-%m-%d %H:%M:%S')
|
|
return os.path.join(upload_path, conllection_code, str(t[0]))
|
|
|
|
|
|
def file_store_path_month(data_str_time, upload_path, conllection_code):
|
|
"""
|
|
目录到月
|
|
:param upload_path:
|
|
:param data_str_time:
|
|
:return:
|
|
"""
|
|
t = time.strptime(data_str_time, '%Y-%m-%d %H:%M:%S')
|
|
return os.path.join(upload_path, conllection_code, str(t[0]), str(t[1]))
|
|
|
|
|
|
def file_store_path_day(data_str_time, upload_path, conllection_code):
|
|
"""
|
|
目录到日
|
|
:param upload_path:
|
|
:param data_str_time: 字符串类型的时间
|
|
:return:
|
|
"""
|
|
t = time.strptime(data_str_time, '%Y-%m-%d %H:%M:%S')
|
|
return os.path.join(upload_path, conllection_code, str(t[0]), str(t[1]), str(t[2]))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# time_stamp1 = time.time()
|
|
# print(time_stamp1)
|
|
str_time = '2020-06-08 09:33:07'
|
|
t = time.strptime(str_time, '%Y-%m-%d %H:%M:%S')
|
|
# path = os.path.join('../upload', str(t[0]), str(t[1]), str(t[2]))
|
|
# if not os.path.exists(path):
|
|
# os.makedirs(path)
|
|
# print(path)
|
|
# time_stamp = float(time_stamp1)
|
|
# now = int(round(time_stamp * 1000))
|
|
# t = time.localtime(now / 1000)
|
|
# print(t)
|
|
|
|
# list1 = ['张三', '李四']
|
|
# token_s = dms_login()
|
|
# dms_list = dms_sensing_data(token_s)
|
|
# 数据库返回值
|
|
# list2 = ['张三', '李四']
|
|
|
|
# d = [y for y in list2 if y not in list1]
|
|
# if d is None or len(d) == 0:
|
|
# print("d为空")
|
|
# else:
|
|
# print(d)
|
|
# file_dir = 'C:/Users/HP/Desktop/数管/'
|
|
# dir_list = os.listdir(file_dir)
|
|
# print(dir_list)
|
|
# timestring = '2016-12-21 10:22:56'
|
|
# print(time.mktime(time.strptime(timestring, '%Y-%m-%d %H:%M:%S'))) # 1482286976.0
|
|
print(t)
|