编辑代码

# coding:utf-8
#JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
#print("Hello world!   -  python.jsrun.net .")
import time
import random
from rich import print
from rich.console import Console
from rich.text import Text

console = Console()

def cyber_rain():
    chars = "01█▓▒░┼╬╩╦╣╠╗╝║═╚╔╤╥╙╘╒╓╫╪┘┌┐└├─"
    colors = ["#00ff00", "#00dd00", "#00bb00", "#009900", "#44ff44", "#88ff88"]
    
    try:
        while True:
            console.clear()
            width, height = console.size
            grid = []
            
            for y in range(height-2):
                line = Text()
                speed = int(y * 0.3)
                for x in range(width):
                    if random.random() < 0.05 or (y > 3 and grid[y-4][x] == " "):
                        char = random.choice(chars)
                        color = colors[min(y//2, len(colors)-1)]
                        style = f"bold {color} on black"
                    else:
                        char = " "
                        style = ""
                    line.append(char, style)
                grid.append(line)
            
            for line in grid:
                console.print(line)
            
            text = Text("CYBER PYTHON 2077", justify="center")
            text.stylize("bold cyan on black", 0, 6)
            text.stylize("bold yellow on black", 7, 13)
            text.stylize("bold magenta on black", 14, 20)
            console.print(text)
            
            time.sleep(0.1)

    except KeyboardInterrupt:
        console.print("\n[bold magenta]System shutdown initiated...[/]")

if __name__ == "__main__":
    cyber_rain()