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()

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

运行结果:

相关推荐
MATLAB代码顾问1 天前
5大智能算法优化标准测试函数对比(Python实现)
开发语言·python
ting94520001 天前
Tornado 全栈技术深度指南:从原理到实战
人工智能·python·架构·tornado
果汁华1 天前
Browserbase Skills:让 Claude Agent 真正“看见“网页世界
人工智能·python
ZhengEnCi1 天前
04-缩放点积注意力代码实现 💻
人工智能·python
DeepReinforce1 天前
三、AI量化投资:使用akshare获取A股主板20260430所有的涨停股票
python·量化·akshare·龙头战法
段一凡-华北理工大学1 天前
【高炉炼铁领域炉温监测、预警、调控智能体设计与应用】~系列文章08:多模态数据融合:让数据更聪明
人工智能·python·高炉炼铁·ai赋能·工业智能体·高炉炉温
万粉变现经纪人1 天前
如何解决 pip install llama-cpp-python 报错 未安装 CMake/Ninja 或 CPU 不支持 AVX 问题
开发语言·python·开源·aigc·pip·ai写作·llama
其实防守也摸鱼1 天前
CTF密码学综合教学指南--第五章
开发语言·网络·笔记·python·安全·网络安全·密码学
callJJ1 天前
Spring Data Redis 两种编程模型详解:同步 vs 响应式
java·spring boot·redis·python·spring
小郑加油1 天前
python学习Day12:pandas安装与实际运用
开发语言·python·学习