许多语言库(C、Python、Ruby、PHP、PERL 等)中都有
strptime
函数。
它似乎基于 Open Group 的
time.h
规范。
我理解“str”代表字符串,“time”显然代表时间,但是“p”代表什么?解析?指针?打印?
每次我接触到 strptime() 函数时,我的大脑一片空白,必须在手册中查找该名称。我想如果我最终弄清楚它代表什么,也许我就有机会记住它。
大部分地方我都找到了
strftime() -> 字符串格式时间 &
strptime() -> 字符串解析时间
我有同样的问题,我要使用 put:
strftime -> 'string from time'
strptime -> 'string, put time'
它帮助我记住:
我认为
strftime()
是来自时间的字符串。函数 strptime()
可能源自字符串解析时间。
这是记住这一点的另一种方式:
f 代表 from,str f time (strftime)-> 字符串 from time
p 表示生产,str p time (strptime)-> 字符串生产时间
我的助记词供大家参考:
strptime
= str 指向时间 = str -> 时间。
strftime
= 时间的 str = str <- time.
这是我发现有帮助的肺炎:
strftime
-> string (forward) time :此函数从 time 对象 进行转换
strptime
-> string(previous)时间:此函数从 string 对象 进行转换
strftime:将日期时间格式化为字符串
strptime:parse将字符串转换为日期时间