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

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

运行结果:

相关推荐
m***记5 分钟前
Python 数据分析入门:Pandas vs NumPy 全方位对比
python·数据分析·pandas
MYX_30913 分钟前
第七章 完整的模型训练
pytorch·python·深度学习·学习
新子y30 分钟前
【小白笔记】岛屿数量
笔记·python
CLubiy35 分钟前
【研究生随笔】Pytorch中的线性代数
pytorch·python·深度学习·线性代数·机器学习
reasonsummer38 分钟前
【办公类-115-02】20251018信息员每周通讯上传之文字稿整理(PDF转docx没有成功)
python·pdf
材料科学研究1 小时前
深度学习物理神经网络(PINN)!
python·深度学习·神经网络·pinn
兰文彬1 小时前
Pytorch环境安装指南与建议
人工智能·pytorch·python
哦你看看1 小时前
学习Python 03
开发语言·windows·python
后端小张1 小时前
[AI 学习日记] 深入解析MCP —— 从基础配置到高级应用指南
人工智能·python·ai·开源协议·mcp·智能化转型·通用协议
天青色等烟雨..1 小时前
AI+Python驱动的无人机生态三维建模与碳储/生物量/LULC估算全流程实战技术
人工智能·python·无人机