python time方法疑惑
time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())time.strftime("%Y-%m-%d %H:%M:%S")
为什么这两个执行结果是一样的呢 因为time.strftime("%Y-%m-%d %H:%M:%S")默认调用参数就是time.localtime() 看源码
def strftime(format, p_tuple=None): # real signature unknown; restored from __doc__
"""
strftime(format[, tuple]) -> string
Convert a time tuple to a string according to a format specification.
See the library reference manual for formatting codes. When the time tuple
is not present, current time as returned by localtime() is used.
这句话的意思是,当时间元组(也就是第二个参数)不存在,则使用localtime()返回的当前时间。
页:
[1]