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

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

运行结果:

相关推荐
虎虎(_ _)。゜zzZ7 小时前
SQLAlchemy入门教程
数据库·后端·python·sql·ai·sqlalchemy
BUG研究员_8 小时前
LangGraph持久化之失败后恢复运行
python·agent
gb42152878 小时前
数字人面试和RAG区别?
python
宁渡AI大模型8 小时前
AI 全栈面试新趋势:Vibe Coding、前端、Java 后端高频面试题深度解析|河南宁渡科技有限公司编程教程
java·javascript·人工智能·python·ai大模型
Groundwork Explorer8 小时前
ESP32-C3 SuperMini 排查WIFI收发故障
python·单片机·嵌入式硬件·mcu
智购科技自动售货机工厂8 小时前
2026自动售货机端侧AI降本逻辑:从云端API到本地推理的成本重构~YH
人工智能·python·ui·面试·交互
Data_Journal8 小时前
如何将网页抓取用于机器学习
大数据·开发语言·数据库·python·scrapy
郝学胜-神的一滴9 小时前
Effective Python 条款 13:善用星号解包,告别下标切片拆分的坑
服务器·开发语言·数据结构·python·程序人生·pycharm
IvanCodes9 小时前
Python 基础语法(五):列表与元组
python