Commit 1bc31d04 by BellCodeEditor

save project

parent 4ea4d147
Showing with 6 additions and 36 deletions
import turtle
import random
import wordcloud
pen = turtle.Turtle()
pen.color('sienna')
pen.speed(0)
w = turtle.Screen()
w.bgcolor('wheat')
with open('python二级考试大纲。txt',encoding ='utf-8')as f
text = f.read()
pen.left(90)
pen.up()
pen.backward(150)
pen.down()
def tree(n):
if n >= 50:
pen.forward(n)
pen.right(30)
tree(n-10)
pen.left(60)
tree(n-10)
pen.right(30)
pen.up()
pen.backward(n)
pen.down()
w = wordcloud.WordCloud(background_color="white,"font_path='SimHei.ttf')
pen = turtle.Turtle()
pen.color('sienna')
w = turtle.Screen()
w.bgcolor()
w.generate(text)
pen.left(90)
pen.up()
pen.backward(150)
pen.down()
tree(60)
turtle.done()
\ No newline at end of file
w.to_file("mycloud.png")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment