database_tools中新增将日期字符串转为整形日期的函数datestrtotimestamp
This commit is contained in:
parent
0f9ee811ac
commit
3d664d7816
|
|
@ -30,6 +30,11 @@ def GetTime(): #获得当前时间
|
||||||
currenttime = f"{t.tm_hour:0>2}{t.tm_min:0>2}{t.tm_sec:0>2}"
|
currenttime = f"{t.tm_hour:0>2}{t.tm_min:0>2}{t.tm_sec:0>2}"
|
||||||
return currenttime #返回当前时间hhmmss
|
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): #读取文本格式的文件
|
def ReadTextFile(filepath): #读取文本格式的文件
|
||||||
with open(filepath,"r",encoding="u8") as f:
|
with open(filepath,"r",encoding="u8") as f:
|
||||||
data = f.read()
|
data = f.read()
|
||||||
|
|
|
||||||
Reference in New Issue