database_tools中新增将日期字符串转为整形日期的函数datestrtotimestamp

This commit is contained in:
wangweiye7840 2024-03-26 13:01:07 +08:00
parent 0f9ee811ac
commit 3d664d7816
1 changed files with 5 additions and 0 deletions

View File

@ -30,6 +30,11 @@ def GetTime(): #获得当前时间
currenttime = f"{t.tm_hour:0>2}{t.tm_min:0>2}{t.tm_sec:0>2}"
return currenttime #返回当前时间hhmmss
def datestrtotimestamp(date_str): # 将yyyymmdd的时间转为时间戳timestamp(以分钟为单位的整数)
date_obj = time.strptime(date_str, "%Y%m%d")
timestamp = int(time.mktime(date_obj))
return timestamp
def ReadTextFile(filepath): #读取文本格式的文件
with open(filepath,"r",encoding="u8") as f:
data = f.read()