Python--获取当前日期和时间(含中文格式)
2019-03-22 21:59
531 查看
获取当天日期
调用locale函数
调用time函数
def get_current_date(is_chinese=False): import time import locale if not is_chinese : return time.strftime('%Y-%m-%d') elif is_chinese: locale.setlocale(locale.LC_CTYPE, 'chinese') return time.strftime('%Y年%m月%d日')
#运行结果
#>>> get_current_date(True)
#‘2019年03月19日’
#>>> get_current_date()
#‘2019-03-19’
获取当前时间
def get_current_time(is_chinese=False): import time import locale if not is_chinese : return time.strftime('%Y-%m-%d %H:%M:%S') elif is_chinese: locale.setlocale(locale.LC_CTYPE, 'chinese') return time.strftime('%Y年%m月%d日%H时%M分%S秒')
#运行结果
次设定为群#>>> get_current_time()
#‘2019-03-19 07:09:07’
#>>> get_current_time(True)
#‘2019年03月19日07时09分13秒’
#>>>
相关文章推荐
- python 获取当前时间 日期 时间戳格式化 参数
- js 获取当前日期时间 格式为 yyyy-mm-dd hh:MM:ss
- js获取当前的日期时间 格式“yyyy-MM-dd HH:MM:SS”
- PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- Python获取并输出当前日期时间
- js 按照特定日期格式获取当前时间
- PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- js 获取当前日期时间 格式为 yyyy-mm-dd hh:MM:ss
- PHP获取当前时间、时间戳的各种格式写法汇总[日期时间]
- Java 以指定日期时间格式获取当前时间、以及每隔一秒刷新一次的方法------附带实例
- python 利用time模块获取当前 日期时间
- Python:如何获取当前的日期和时间
- JAVA,jsp,oracle获取系统当前时间以及日期格式转换!
- python获取当前日期和时间的方法
- js获取当前日期,并转化为时间格式“YYYY-MM-DD HH:MM:SS”
- UIDatePicke获取当前时间的年、月、日、时、分、秒, //显示成中文格式的
- Python:如何获取当前的日期和时间
- 创建一个Date.text文件,获取当前的日期,将日期格式为“2013/02/14 05:20:00”的形式。然后一秒钟记录一次,将新的时间存入到文件中。