以下是一个简单的Python程序,可以展示当前时间:

import datetime

now = datetime.datetime.now()
print("当前时间:")
print(now.strftime("%Y-%m-%d %H:%M:%S"))

输出结果类似于:

当前时间:
2021-07-19 23:15:30

这个程序使用了Python的datetime模块,通过调用now()函数获取当前时间,并使用strftime()函数将时间格式化为字符串输出。

请帮我生成一个python程序展示现在的时间。

原文地址: https://www.cveoy.top/t/topic/Gko 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录