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

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

运行结果:

相关推荐
Mikhail_G18 分钟前
Python应用变量与数据类型
大数据·运维·开发语言·python·数据分析
hello kitty w1 小时前
Python学习(7) ----- Python起源
linux·python·学习
站大爷IP1 小时前
Python文本序列的类型
python
千千寰宇1 小时前
[Java/Python] Java 基于命令行调用 Python
python·java se-jdk/jvm
yvestine2 小时前
自然语言处理——文本表示
人工智能·python·算法·自然语言处理·文本表示
zzc9212 小时前
MATLAB仿真生成无线通信网络拓扑推理数据集
开发语言·网络·数据库·人工智能·python·深度学习·matlab
编程有点难2 小时前
Python训练打卡Day43
开发语言·python·深度学习
2301_805054563 小时前
Python训练营打卡Day48(2025.6.8)
pytorch·python·深度学习
LjQ20403 小时前
网络爬虫一课一得
开发语言·数据库·python·网络爬虫
哆啦A梦的口袋呀3 小时前
基于Python学习《Head First设计模式》第九章 迭代器和组合模式
python·学习·设计模式