Update flag.py

pull/526/head
Lazyaqu 2020-04-03 19:56:49 +08:00 committed by GitHub
parent dbe54797b0
commit 56eac4137d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -1,7 +1,9 @@
""" """
用Python的turtle模块绘制国旗 用Python的turtle模块绘制国旗
""" """
import turtle from turtle import Turtle,Screen
turtle = Turtle()
screen = Screen()
def draw_rectangle(x, y, width, height): def draw_rectangle(x, y, width, height):
@ -10,7 +12,7 @@ def draw_rectangle(x, y, width, height):
turtle.pencolor('red') turtle.pencolor('red')
turtle.fillcolor('red') turtle.fillcolor('red')
turtle.begin_fill() turtle.begin_fill()
for i in range(2): for _ in range(2):
turtle.forward(width) turtle.forward(width)
turtle.left(90) turtle.left(90)
turtle.forward(height) turtle.forward(height)
@ -67,8 +69,8 @@ def main():
# 隐藏海龟 # 隐藏海龟
turtle.ht() turtle.ht()
# 显示绘图窗口 # 显示绘图窗口
turtle.mainloop() screen.mainloop()
if __name__ == '__main__': if __name__ == '__main__':
main() main()