Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1865742
  • 博文数量: 273
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 2000
  • 用 户 组: 普通用户
  • 注册时间: 2014-03-31 14:30




分类: Python/Ruby

2016-04-16 18:09:51

import time

print (time.strftime('%Y-%m-%d %H:%M:%S'))

print (time.strftime('%Y-%m-%d %H:%M:%S',time.localtime()))


>>> help(time.strftime)
Help on built-in function strftime in module time:

    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.
    Commonly used format codes:
    %Y  Year with century as a decimal number.
    %m  Month as a decimal number [01,12].
    %d  Day of the month as a decimal number [01,31].
    %H  Hour (24-hour clock) as a decimal number [00,23].
    %M  Minute as a decimal number [00,59].
    %S  Second as a decimal number [00,61].
    %z  Time zone offset from UTC.
    %a  Locale's abbreviated weekday name.
    %A  Locale's full weekday name.
    %b  Locale's abbreviated month name.
    %B  Locale's full month name.
    %c  Locale's appropriate date and time representation.
    %I  Hour (12-hour clock) as a decimal number [01,12].
    %p  Locale's equivalent of either AM or PM.
    Other codes may be available on your platform.  See documentation for
    the C library strftime function.

阅读(419) | 评论(0) | 转发(0) |