安装扩展
pip3 install python-dateutil
定义字符串变量:
logline = 'INFO 2020-01-01T00:00:01 Happy new year, human.'
示例:
from dateutil.parser import parse
timestamp = parse(log_line, fuzzy=True)
print(timestamp)
结果:
2020-01-01 00:00:01
pip3 install python-dateutil
logline = 'INFO 2020-01-01T00:00:01 Happy new year, human.'
from dateutil.parser import parse
timestamp = parse(log_line, fuzzy=True)
print(timestamp)
2020-01-01 00:00:01
评论区