目录
1、样式一:普通图案
2、样式二:3D立体图案
1、样式一:普通图案
脚本代码:
#!/usr/bin/env python# -*- coding: utf-8 -*-# 公众号:AllTests软件测试importtime# 打印爱心图案defprint_love():myData ="love"forcharinmyData.split():allChar = []foryinrange(12,-12,-1):lst = []lst_con =''forxinrange(-30,30):formula = ((x *0.05) **2+ (y *0.1) **2-1) **3- (x *0.05) **2* (y *0.1) **3ifformula <=0:lst_con += char[(x) % len(char)]else:lst_con +=' 'lst.append(lst_con)allChar += lstprint('\n'.join(allChar))time.sleep(1)if__name__ =='__main__':print_love()
运行结果:
2、样式二:3D立体图案
脚本代码:
#!/usr/bin/env python# -*- coding: utf-8 -*-# 公众号:AllTests软件测试importmatplotlib.pyplotaspltimportnumpyasnpimporttime# 打印爱心3D图案defprint_love3D():start = time.time()x_lim, y_lim, z_lim = np.linspace(-10,10,520), np.linspace(-10,10,520), np.linspace(-10,10,520)X_points, Y_points, Z_points = [], [], []forxinx_lim:foryiny_lim:forzinz_lim:if(x**2+(9/4)*y**2+z**2-1)**3-(9/80)*y**2*z**3-x**2*z**3<=0:X_points.append(x)Y_points.append(y)Z_points.append(z)end = time.time()fig = plt.figure()ax = fig.add_subplot(111, projection='3d')ax.scatter(X_points, Y_points, Z_points, s=20, alpha=0.5, color="red")plt.show()print(end-start)if__name__ =='__main__':print_love3D()
运行结果(需要等待一段时间):
精彩推荐
面试笔试系列
思维导图系列
Linux常用命令壁纸
接口Requests系列
测试框架pytest系列
Jmeter快速上手之接口测试
自动化测试框架结构图
移动安全框架(MobSF)