Deepseek-R1 AI大模型写的一段程序

佚名1年前 (2025-02-24)AI测评2270

请用Python写一个数字时钟,以字符方式显示当前时间,在原位置每秒刷新一次数字。


import time
import os

# 字符艺术表示的大数字(放大5倍)
DIGITS = {
    '0': [
        "  #####  ",
        " ##   ## ",
        "##     ##",
        "##     ##",
        "##     ##",
        " ##   ## ",
        "  #####  "
    ],
    '1': [
        "   ##   ",
        " ####   ",
        "   ##   ",
        "   ##   ",
        "   ##   ",
        "   ##   ",
        " ###### "
    ],
    '2': [
        " ####### ",
        "##     ##",
        "       ##",
        " ####### ",
        "##       ",
        "##       ",
        " ########"
    ],
    '3': [
        " ####### ",
        "##     ##",
        "       ##",
        " ####### ",
        "       ##",
        "##     ##",
        " ####### "
    ],
    '4': [
        "##     ##",
        "##     ##",
        "##     ##",
        " ########",
        "       ##",
        "       ##",
        "       ##"
    ],
    '5': [
        " ####### ",
        "##       ",
        "##       ",
        " ####### ",
        "       ##",
        "##     ##",
        " ####### "
    ],
    '6': [
        " ####### ",
        "##      ",
        "##      ",
        " #######",
        "##     ##",
        "##     ##",
        " ####### "
    ],
    '7': [
        "########",
        "      ##",
        "      ##",
        "     ## ",
        "    ##  ",
        "   ##   ",
        "  ##    "
    ],
    '8': [
        " ####### ",
        "##     ##",
        "##     ##",
        " ####### ",
        "##     ##",
        "##     ##",
        " ####### "
    ],
    '9': [
        " ####### ",
        "##     ##",
        "##     ##",
        " ####### ",
        "       ##",
        "##     ##",
        " ####### "
    ],
    ':': [
        "        ",
        "        ",
        "   ##   ",
        "        ",
        "   ##   ",
        "        ",
        "        "
    ]
}

def print_large_time(time_str):
    lines = [''] * 7
    for char in time_str:
        if char in DIGITS:
            for i, line in enumerate(DIGITS[char]):
                lines[i] += line + ' '
        else:
            for i in range(7):
                lines[i] += '        '
    return lines

def clear_screen():
    # 根据操作系统清除屏幕
    if os.name == 'nt':
        os.system('cls')
    else:
        os.system('clear')

def display_clock():
    while True:
        # 获取当前时间
        current_time = time.strftime('%H:%M:%S')
        
        # 清除屏幕
        clear_screen()
        
        # 打印大字时间
        large_time_lines = print_large_time(current_time)
        for line in large_time_lines:
            print(line)
        
        # 等待一秒钟
        time.sleep(1)

display_clock()


(交互过程省略一千字……)


运行效果图:

clock.png


相关文章

智能体革命:一场正在重构人类社会的静默变迁

智能体革命:一场正在重构人类社会的静默变迁  (2025年3月6日产业观察手记)当机器开始思考:产业前线的真实图景深圳龙岗区的比亚迪第九工厂,凌晨三点的车间依然灯火通明。12台搭载...

AI 编程工具 Cursor IDE的一些小秘密

AI 编程工具 Cursor IDE的一些小秘密

Cursor 工具调用 工具名称 (Name) 描述 (Description) 主要参数 (Parameters) codebase_search 从代码库中查找与...