首页 > 分享 > 今天520! 教你用Python浪漫表白

今天520! 教你用Python浪漫表白

今天是520,如果你有意中人, 赶紧抓住机会表白!

Python浪漫表白!

Python具有超强大的绘图功能,可以在你准备表白时祝你一臂之力.

Python导包

import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits.mplot3d import Axes3D 123456'

先送一朵玫瑰花

fig = plt.figure(figsize=(12, 10)) ax = fig.gca(projection='3d') [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 30 * np.pi - 4*np.pi ) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) change = np.sin(20*t)/50 u = 1 - (1 - np.mod(3.3 * t, 2 * np.pi) / np.pi) ** 4 / 2 + change y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5 h = u * (x * np.cos(p) - y * np.sin(p)) c = plt.get_cmap('magma') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True) plt.show()

1234567891011121314151617

什么! 颜色太单一? 那来个五颜六色的

fig = plt.figure(figsize=(12, 10)) ax = fig.gca(projection='3d') [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 17 * np.pi - 2 * np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) u = 1 - (1 - np.mod(3.6 * t, 2 * np.pi) / np.pi) ** 4 / 2 y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) h = u * (x * np.cos(p) - y * np.sin(p)) c = cm.gist_rainbow_r surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True) plt.show()

12345678910111213141516

在这里插入图片描述

把绿色去掉, 保留玫瑰花的红色

fig = plt.figure(figsize=(12, 10)) ax = fig.gca(projection='3d') [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 17 * np.pi - 2 * np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) u = 1 - (1 - np.mod(3.6 * t, 2 * np.pi) / np.pi) ** 4 / 2 y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) h = u * (x * np.cos(p) - y * np.sin(p)) c= cm.get_cmap('spring_r') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True) plt.show()

12345678910111213141516

在这里插入图片描述

玫瑰花盛开! 祝你表白成功!

fig = plt.figure(figsize=(12, 10)) ax = fig.gca(projection='3d') [x, t] = np.meshgrid(np.array(range(25)) / 24.0, np.arange(0, 575.5, 0.5) / 575 * 6 * np.pi - 4*np.pi) p = (np.pi / 2) * np.exp(-t / (8 * np.pi)) change = np.sin(10*t)/20 u = 1 - (1 - np.mod(5.2 * t, 2 * np.pi) / np.pi) ** 4 / 2 + change y = 2 * (x ** 2 - x) ** 2 * np.sin(p) r = u * (x * np.sin(p) + y * np.cos(p)) * 1.5 h = u * (x * np.cos(p) - y * np.sin(p)) c= plt.get_cmap('spring_r') surf = ax.plot_surface(r * np.cos(t), r * np.sin(t), h, rstride=1, cstride=1, cmap= c, linewidth=0, antialiased=True) plt.show()

123456789101112131415161718

在这里插入图片描述

用Python海龟画图表白

import turtle import random # 输入你爱人的姓名: my_love = "刘亦菲" def love(x, y): lv = turtle.Turtle() lv.hideturtle() lv.up() lv.goto(x, y) # 定位到(x,y) def curvemove(): # 画圆弧 for i in range(20): lv.right(10) lv.forward(2) lv.color('red', 'pink') lv.speed(10000) lv.pensize(1) # 开始画爱心 lv.down() lv.begin_fill() lv.left(140) lv.forward(22) curvemove() lv.left(120) curvemove() lv.forward(22) lv.write(my_love, font=("Arial", 12, "normal"), align="center") lv.left(140) lv.end_fill() def tree(branchLen, t): if branchLen > 5: if branchLen < 20: t.color("blue") t.pensize(random.uniform((branchLen + 5) / 4 - 2, (branchLen + 6) / 4 + 5)) t.down() t.forward(branchLen) love(t.xcor(), t.ycor()) t.up() t.backward(branchLen) t.color("brown") return t.pensize(random.uniform((branchLen + 5) / 4 - 2, (branchLen + 6) / 4 + 5)) t.down() t.forward(branchLen) # 递归 ang = random.uniform(15, 45) t.right(ang) tree(branchLen - random.uniform(12, 16), t) t.left(2 * ang) tree(branchLen - random.uniform(12, 16), t) t.right(ang) t.up() t.backward(branchLen) myWin = turtle.Screen() t = turtle.Turtle() t.hideturtle() t.speed(100) t.left(90) t.up() t.backward(200) t.down() t.color("brown") t.pensize(32) t.forward(60) tree(100, t) myWin.exitonclick()

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879

在这里插入图片描述

上面我们用到的是Matplotlib绘图和Python绘图, 想了解更多的话,可以微信扫码下方CSDN官方账号,免费领取资料哦~

零基础Python学习资源介绍

一、Python所有方向的学习路线

Python所有方向路线就是把Python常用的技术点做整理,形成各个领域的知识点汇总,它的用处就在于,你可以按照上面的知识点去找对应的学习资源,保证自己学得较为全面。
在这里插入图片描述

二、Python学习软件

工欲善其事,必先利其器。学习Python常用的开发软件都在这里了!
在这里插入图片描述

三、Python入门学习视频

还有很多适合0基础入门的学习视频,有了这些视频,轻轻松松上手Python~在这里插入图片描述

四、Python练习题

每节视频课后,都有对应的练习题哦,可以检验学习成果哈哈!
在这里插入图片描述

五、Python实战案例

光学理论是没用的,要学会跟着一起敲代码,动手实操,才能将自己的所学运用到实际当中去,这时候可以搞点实战案例来学习。这份资料也包含在内的哈~在这里插入图片描述

六、Python面试资料

我们学会了Python之后,有了技能就可以出去找工作啦!下面这些面试题是都来自阿里、腾讯、字节等一线互联网大厂,并且有阿里大佬给出了权威的解答,刷完这一套面试资料相信大家都能找到满意的工作。
在这里插入图片描述
在这里插入图片描述

七、资料领取

上述完整版Python全套学习资料已经上传CSDN官方,需要的小伙伴可自行微信扫描下方CSDN官方认证二维码输入“领取资料”免费领取!!

相关知识

python浪漫表白,表白代码——绘制3D玫瑰花
520送花该如何表白
520表白情话文案(精选480句)
适合520表白的文案(精选450句)
表白现场浪漫布置 浪漫表白现场怎么布置【接亲网】
520表白日你对表白攻略做好准备了吗?方案提前已备好只等你来取
“520”引爆“表白经济”
python表白玫瑰花绘制——情人节表白
520情人节鲜花表白祝福语
520送花卡片内容表白简短句子(精选550句)

网址: 今天520! 教你用Python浪漫表白 https://m.huajiangbk.com/newsview792784.html

所属分类:花卉
上一篇: 怎么向女生表白才容易被接受,送什
下一篇: 送花你送对了吗?花所代表的爱的涵