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

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

运行结果:

相关推荐
蔚说1 分钟前
is 与 == 的区别 python
python
cnxy1885 分钟前
围棋对弈Python程序开发完整指南:步骤3 - 气(Liberties)的计算算法设计
python·算法·深度优先
叶子20242222 分钟前
骨架点排序计算
python
AC赳赳老秦36 分钟前
行业数据 benchmark 对比:DeepSeek上传数据生成竞品差距分析报告
开发语言·网络·人工智能·python·matplotlib·涛思数据·deepseek
小鸡吃米…39 分钟前
带Python的人工智能——深度学习
人工智能·python·深度学习
胡伯来了1 小时前
07 - 数据收集 - 网页采集工具Scrapy
python·scrapy·数据采集
御水流红叶1 小时前
第七届金盾杯(第一次比赛)wp
开发语言·python
小徐Chao努力1 小时前
【Langchain4j-Java AI开发】04-AI 服务核心模式
java·人工智能·python
白日做梦Q1 小时前
预训练模型微调(Finetune)实战:策略、技巧及常见误区规避
人工智能·python·神经网络·机器学习·计算机视觉
历程里程碑1 小时前
双指针巧解LeetCode接雨水难题
java·开发语言·数据结构·c++·python·flask·排序算法