← 返回题库
初级

时间处理

未完成
初级参考 完整示例代码供参考,建议自己理解后重新输入
def solve():
    import time
    current = time.localtime()
    print(f"当前时间: {time.strftime('%Y-%m-%d %H:%M:%S', current)}")
    weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
    print(f"今天是: {weekdays[current.tm_wday]}")

示例

输入
solve()
期望输出
当前时间: 2026-04-04 22:13:07
今天是: 星期六
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码