Skip to content

Instantly share code, notes, and snippets.

@SolemnJoker
Last active May 11, 2021 09:07
Show Gist options
  • Save SolemnJoker/758fe95847b4479620c6fc5302450d09 to your computer and use it in GitHub Desktop.
Save SolemnJoker/758fe95847b4479620c6fc5302450d09 to your computer and use it in GitHub Desktop.
[python unit] #python
import os
rootdir = "./input_files"
paths = os.listdir(rootdir)
for path in paths:
path = os.path.join(rootdir,path)
if os.path.isfile(path):
#...
import time
#时间格式转换,涉及到三个类型,字符串,时间戳,struct_time
#时间戳转字符串
s_time = time.localtime(timestamp)
str_time = time.strftime("%Y/%m/%d %H:%M:%S",s_time)
#字符串转时间戳
s_time = time.strptime(str_time,"%Y/%m/%d %H:%M:%S")
snapTime = time.mktime(s_time)

匹配子字符串

 re.findall(r'snappedAt\[[0-9]{10}\]',inputString)

返回所有匹配的字符串数组

替换

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment