Python turtle库 实现 随机彩色文字平面批量输出

python 复制代码
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import turtle
import random
import turtle as t
t.colormode(255)
turtle.bgcolor("white")
h=255
l=50#字号
m=60#间隔
n=500
t.penup()
turtle.hideturtle()
def wuxing():
    turtle.pu()
    #turtle.penup()
    
    #turtle.stamp()#central
    #turtle.right(90)
    text="二叉树"
    #turtle.pu()
    for i in text:
        e=random.randint(0,h)
        f=random.randint(0,h)
        g=random.randint(0,h)
        turtle.pencolor(e,f,g)
        turtle.write(i,font=('隶书',l))
        t.fd(m)
t.speed(10000)
for i in range(10):
    turtle.goto(-800, n)  # 到画布中心
    n-=100
    for j in range(10):
        wuxing()

声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

运行结果:

相关推荐
C137的本贾尼15 分钟前
MCP 完全指南:从零开始掌握模型上下文协议
人工智能·python
威联通安全存储1 小时前
SMT表面贴装线AOI检测网中TS-h2287XU-RP混合架构的物理部署
python·架构
大鱼>1 小时前
Scikit-learn Pipeline:构建可复用的 ML 流水线
python·机器学习·scikit-learn
闲猫1 小时前
深入理解 Skills:从 API 调用到智能体行为封装
人工智能·python·langchain
还是鼠鼠1 小时前
AI掘金头条新闻系统 (Toutiao News)-缓存相关推荐新闻
后端·python·mysql·fastapi·web
骑士雄师1 小时前
大模型:runnable
python·embedding
2401_868534782 小时前
系统分析师案例分析题常考知识点
python·计算机网络
江华森2 小时前
Python 实现 2048 游戏(三):面向对象重构与AI模拟
python
可以飞的话3 小时前
五、数据处理1
python
鱼毓屿御3 小时前
Python 装饰器与函数调用机制(复习笔记 · 2026-07-07)
开发语言·python