python3 turtle 画国际象棋棋盘 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wan import turtle n = 60 # 每行间隔 x = -300 # x初始值 y = -300 # x初始值 turtle.speed(11) turtle.pensize(2) # 先画8*8的正方形,并按要求涂黑 for i in range(8): for j in range(1, 9): turtle…
import turtle as t t.speed(10) t.pencolor("yellow") t.fillcolor("red") for num in range(1,6): for i in range(1,5): t.forward(200) t.right(144) t.forward(200) t.goto(num*50,num*50) t.penup() t.goto(-100,-200) t.color('green','red') for…
1 标准输出 python3利用 print() 来实现标准输出 def print(self, *args, sep=' ', end='\n', file=None): # known special case of print """ print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by d…
文本进度条实例 #!/usr/bin/env python3 import time #for i in range(101): # print ("\r{:3.0f}%".format(i),end="") # time.sleep(0.1) scale = 50 print("执行开始".center(scale//2,"-")) start = time.perf_counter() for i in range(sca…
前言 最近翻到一篇知乎,上面有不少用Python(大多是turtle库)绘制的树图,感觉很漂亮,整理了一下,挑了一些觉得不错的代码分享给大家(这些我都测试过,确实可以生成喔~赶快去试一下吧) one 樱花树 动态生成樱花 效果图(这个是动态的): 实现代码: import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): time.sleep(0.0005) if branch > 3: if 8…