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

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

运行结果:

相关推荐
Amelia1111116 小时前
day47
python
Chris_12197 小时前
Halcon学习笔记-Day6进阶:工业级视觉系统核心技术详解
人工智能·python·深度学习·halcon
飞鸟真人8 小时前
关于python -m http.server的一些安全问题
python·安全·http
tjjucheng8 小时前
小程序定制开发哪家性价比高
python
No0d1es8 小时前
2025年12月 GESP CCF编程能力等级认证Python六级真题
python·青少年编程·gesp·ccf·六级
亮子AI8 小时前
【Python】比较两个cli库:Click vs Typer
开发语言·python
CappuccinoRose8 小时前
流计算概述
python·flink·流计算·数据流·pyflink
Dragon水魅8 小时前
Fandom Wiki 网站爬取文本信息踩坑实录
爬虫·python
Darkershadow8 小时前
蓝牙学习之unprovision beacon
python·学习·ble