十几款拿来就能用的炫酷表白代码

「作者主页」:士别三日wyx
「作者简介」:CSDN top100、阿里云博客专家、华为云享专家、网络安全领域优质创作者
「推荐专栏」:小白零基础《Python入门到精通》

表白代码

  • 1、坐我女朋友好吗,不同意就关机.vbs
  • 2、坐我女朋友好吗,不同意关不掉.vbs
  • 3、动态粒子效果.html
  • 4、爱心动态.html
  • 5、爱心跳动.html
  • 6、弹窗表白.py
  • 7、一行代码实现心形.py
  • 8、一箭穿心.py
  • 9、爱心.py
  • 10、爱心代码.py
  • 11、爱心发射.py
  • 12、玫瑰花.py
  • 粉丝福利

1、坐我女朋友好吗,不同意就关机.vbs

复制到文本文件,后缀名改成vbs就能运行,效果如下。

在这里插入图片描述
在这里插入图片描述

完整代码如下,复制就能用

Set Seven = WScript.CreateObject("WScript.Shell")
strDesktop = Seven.SpecialFolders("AllUsersDesktop")
set oShellLink = Seven.CreateShortcut(strDesktop & "\\Seven.url")
oShellLink.Save
se_key = (MsgBox("我喜欢你很久了,你可以做我女朋友吗 是=同意 否=拒绝 ",4,"我没有开玩笑!!!"))
If se_key=6 Then
MsgBox "谢谢你给了我这次机会,I Love You",64,"Love you"
Else
seven.Run "shutdown.exe -s -t 600"
agn=(MsgBox ("我真的很喜欢你!求你了,别拒绝我,好吗?是=同意 否=拒绝",4,"别拒绝我,好吗?"))
If agn=6 Then
seven.Run "shutdown.exe -a"
MsgBox "谢谢你给了我这次机会,I Love You",,"Love you"
WScript.Sleep 500
Else
MsgBox "唉,那祝你能找到自己喜欢的人,若可回头,记住,我在你身后一直等你!--爱你的人",64,"祝你幸福!!"
seven.Run "shutdown.exe -a"
MsgBox "其实你拒绝了我,我也不会关你电脑的!因为你是我最重要的人,我不会捉弄你的!",64,"我愿意等你!"
End If
End If

2、坐我女朋友好吗,不同意关不掉.vbs

为了防止有些小伙伴关机后被打,提供了一个替代方案,复制到文本文件,后缀名改成vbs就能运行,效果如下。

在这里插入图片描述

完整代码如下,复制就能用

msgbox ("我有一件事想跟你说"),vbQuestion,("在吗?")
msgbox ("自从第一天遇见你,我便对你难以忘怀了!")
msgbox ("做我女朋友好吗?")
msgbox ("房产写你名字")
msgbox ("保大")
msgbox ("我妈会游泳")
dim j
do while j<1
Select Case msgbox("做我女朋友好吗?",68,"请郑重的回答我!")
Case 6 j=1
Case 7 msgbox("再给你一次机会")
end Select
loop
msgbox("我就知道你会同意的,哈哈哈哈!!")

3、动态粒子效果.html

HTML动态粒子效果,会随着鼠标焦点转动,复制到HTML文件访问即可,效果图如下

在这里插入图片描述

完整代码如下,复制就能用

<!doctype html>
<html>
<head><meta charset="utf-8"><title>canvas五彩斑斓的粒子动画特效</title><style>body {overflow: hidden;margin: 0;padding: 0;background: hsla(242, 30%, 5%, 1);}canvas {width: 100%;}</style></head>
<body><canvas id='canv'></canvas><script>/*(Book REF) HTML5 Canvas Ch. 5:  Math, Physics, and Animation ::: Uniform Circular MotionBy Steve Fulton and Jeff Fulton*/window.requestAnimFrame = (function () {return window.requestAnimationFrame ||window.webkitRequestAnimationFrame ||window.mozRequestAnimationFrame ||window.oRequestAnimationFrame ||window.msRequestAnimationFrame ||function (callback) {window.setTimeout(callback, 1000 / 60);};})();window.addEventListener('load', start, false);var c,$,w,h,msX,msY,midX,midY,num = 650,parts = [],begin = 50,repeat = 20,end = Math.PI * 2,force = null,msdn = false;function start() {c = document.getElementById('canv');$ = c.getContext('2d');w = c.width = window.innerWidth;h = c.height = window.innerHeight;midX = w / 2;midY = h / 2;force = Math.max(w, h) * 0.09;flow = begin;window.requestAnimFrame(create);run();}function run() {window.requestAnimFrame(run);go();}function Part() {this.deg = 0;this.rad = 0;this.x = 0;this.y = 0;this.distX = 0;this.distY = 0;this.color = 'rgb(' + Math.floor(Math.random() * 130) + ',' + Math.floor(Math.random() * 50) + ',' + Math.floor(Math.random() * 100) + ')';this.size;}function create() {var n = num;while (n--) {var p = new Part();p.deg = Math.floor(Math.random() * 360);p.rad = Math.floor(Math.random() * w * 0.5);p.x = p.distX = Math.floor(Math.random() * w);p.y = p.distY = Math.floor(Math.random() * h);p.size = 1 + Math.floor(Math.random() * (p.rad * 0.055));parts[n] = p;}c.onmousemove = msmv;c.onmousedown = msdn;c.onmouseup = msup;var int = setInterval(function () {flow--;if (flow === repeat) clearInterval(int);}, 20);}function go() {$.globalCompositeOperation = 'source-over';$.fillStyle = 'hsla(242, 30%, 5%, .55)';$.fillRect(0, 0, w, h);$.globalCompositeOperation = 'lighter';var mx = msX;var my = msY;var bounds = force;if (msdn) {bounds = force * 2;}var n = num;while (n--) {var p = parts[n];var radi = Math.PI / 180 * p.deg;p.distX = midX + p.rad * Math.cos(radi);p.distY = midY + p.rad * Math.sin(radi) * 0.4;if (mx && my) {var react = Math.floor((bounds * 0.5) + Math.random() * (bounds * 0.9));if (p.distX - mx > 0 &&p.distX - mx < bounds &&p.distY - my > 0 &&p.distY - my < bounds) {p.distX += react;p.distY += react;} else if (p.distX - mx > 0 &&p.distX - mx < bounds &&p.distY - my < 0 &&p.distY - my > -bounds) {p.distX += react;p.distY -= react;} else if (p.distX - mx < 0 &&p.distX - mx > -bounds &&p.distY - my > 0 &&p.distY - my < bounds) {p.distX -= react;p.distY += react;} else if (p.distX - mx < 0 &&p.distX - mx > -bounds &&p.distY - my < 0 &&p.distY - my > -bounds) {p.distY -= react;p.distY -= react;}}p.x += ((p.distX - p.x) / flow);p.y += ((p.distY - p.y) / flow);var x = p.x;var y = p.y;var s = p.size * (p.y * 1.5 / h);if (s < 0.1) {s = 0;}$.beginPath();$.fillStyle = p.color;$.arc(x, y, s, 0, end, true);$.fill();$.closePath();var vary;if (p.size < 2) {vary = 4;} else if (p.size < 3) {vary = 3;} else if (p.size < 4) {vary = 2;} else {vary = 1;}vary *= (p.y / (h * 0.9));p.deg += vary;p.deg = p.deg % 360;}}function msmv(e) {var p = getPos(e.target);var sX = window.pageXOffset;var sY = window.pageYOffset;msX = e.clientX - p.x + sX;msY = e.clientY - p.y + sY;}function msdn(e) {msdn = true;}function msup(e) {msdn = false;}function getPos(el) {var cosmo = {};cosmo.x = el.offsetLeft;cosmo.y = el.offsetTop;while (el.offsetParent) {el = el.offsetParent;cosmo.x += el.offsetLeft;cosmo.y += el.offsetTop;}return cosmo;}</script></body>
</html>

4、爱心动态.html

HTML动态爱心特效,复制到HTML文件访问即可,效果图如下:

在这里插入图片描述

完整代码如下,复制就能用

<!DOCTYPE html>
<html><head><title></title><script src="js/jquery.min.js"></script>
</head>
<style>* {padding: 0;margin: 0;}html,body {height: 100%;padding: 0;margin: 0;background: #000;}.aa {position: fixed;left: 50%;bottom: 10px;color: #ccc;}.container {width: 100%;height: 100%;}canvas {z-index: 99;position: absolute;width: 100%;height: 100%;}
</style><body><!-- 樱花 --><div id="jsi-cherry-container" class="container"><audio autoplay="autopaly"><source src="renxi.mp3" type="audio/mp3" /></audio><img class="img" src="./123.png" alt="" /><!-- 爱心 --><canvas id="pinkboard" class="container"> </canvas></div></body></html>
<script>/** Settings*/var settings = {particles: {length: 500, // maximum amount of particlesduration: 2, // particle duration in secvelocity: 100, // particle velocity in pixels/seceffect: -0.75, // play with this for a nice effectsize: 30, // particle size in pixels},};(function () {var b = 0;var c = ["ms", "moz", "webkit", "o"];for (var a = 0; a < c.length && !window.requestAnimationFrame; ++a) {window.requestAnimationFrame = window[c[a] + "RequestAnimationFrame"];window.cancelAnimationFrame =window[c[a] + "CancelAnimationFrame"] ||window[c[a] + "CancelRequestAnimationFrame"];}if (!window.requestAnimationFrame) {window.requestAnimationFrame = function (h, e) {var d = new Date().getTime();var f = Math.max(0, 16 - (d - b));var g = window.setTimeout(function () {h(d + f);}, f);b = d + f;return g;};}if (!window.cancelAnimationFrame) {window.cancelAnimationFrame = function (d) {clearTimeout(d);};}})();/** Point class*/var Point = (function () {function Point(x, y) {this.x = typeof x !== "undefined" ? x : 0;this.y = typeof y !== "undefined" ? y : 0;}Point.prototype.clone = function () {return new Point(this.x, this.y);};Point.prototype.length = function (length) {if (typeof length == "undefined")return Math.sqrt(this.x * this.x + this.y * this.y);this.normalize();this.x *= length;this.y *= length;return this;};Point.prototype.normalize = function () {var length = this.length();this.x /= length;this.y /= length;return this;};return Point;})();/** Particle class*/var Particle = (function () {function Particle() {this.position = new Point();this.velocity = new Point();this.acceleration = new Point();this.age = 0;}Particle.prototype.initialize = function (x, y, dx, dy) {this.position.x = x;this.position.y = y;this.velocity.x = dx;this.velocity.y = dy;this.acceleration.x = dx * settings.particles.effect;this.acceleration.y = dy * settings.particles.effect;this.age = 0;};Particle.prototype.update = function (deltaTime) {this.position.x += this.velocity.x * deltaTime;this.position.y += this.velocity.y * deltaTime;this.velocity.x += this.acceleration.x * deltaTime;this.velocity.y += this.acceleration.y * deltaTime;this.age += deltaTime;};Particle.prototype.draw = function (context, image) {function ease(t) {return --t * t * t + 1;}var size = image.width * ease(this.age / settings.particles.duration);context.globalAlpha = 1 - this.age / settings.particles.duration;context.drawImage(image,this.position.x - size / 2,this.position.y - size / 2,size,size);};return Particle;})();/** ParticlePool class*/var ParticlePool = (function () {var particles,firstActive = 0,firstFree = 0,duration = settings.particles.duration;function ParticlePool(length) {// create and populate particle poolparticles = new Array(length);for (var i = 0; i < particles.length; i++)particles[i] = new Particle();}ParticlePool.prototype.add = function (x, y, dx, dy) {particles[firstFree].initialize(x, y, dx, dy);// handle circular queuefirstFree++;if (firstFree == particles.length) firstFree = 0;if (firstActive == firstFree) firstActive++;if (firstActive == particles.length) firstActive = 0;};ParticlePool.prototype.update = function (deltaTime) {var i;// update active particlesif (firstActive < firstFree) {for (i = firstActive; i < firstFree; i++)particles[i].update(deltaTime);}if (firstFree < firstActive) {for (i = firstActive; i < particles.length; i++)particles[i].update(deltaTime);for (i = 0; i < firstFree; i++) particles[i].update(deltaTime);}// remove inactive particleswhile (particles[firstActive].age >= duration &&firstActive != firstFree) {firstActive++;if (firstActive == particles.length) firstActive = 0;}};ParticlePool.prototype.draw = function (context, image) {// draw active particlesif (firstActive < firstFree) {for (i = firstActive; i < firstFree; i++)particles[i].draw(context, image);}if (firstFree < firstActive) {for (i = firstActive; i < particles.length; i++)particles[i].draw(context, image);for (i = 0; i < firstFree; i++) particles[i].draw(context, image);}};return ParticlePool;})();/** Putting it all together*/(function (canvas) {var context = canvas.getContext("2d"),particles = new ParticlePool(settings.particles.length),particleRate =settings.particles.length / settings.particles.duration, // particles/sectime;// get point on heart with -PI <= t <= PIfunction pointOnHeart(t) {return new Point(160 * Math.pow(Math.sin(t), 3),130 * Math.cos(t) -50 * Math.cos(2 * t) -20 * Math.cos(3 * t) -10 * Math.cos(4 * t) +25);}// creating the particle image using a dummy canvasvar image = (function () {var canvas = document.createElement("canvas"),context = canvas.getContext("2d");canvas.width = settings.particles.size;canvas.height = settings.particles.size;// helper function to create the pathfunction to(t) {var point = pointOnHeart(t);point.x =settings.particles.size / 2 +(point.x * settings.particles.size) / 350;point.y =settings.particles.size / 2 -(point.y * settings.particles.size) / 350;return point;}// create the pathcontext.beginPath();var t = -Math.PI;var point = to(t);context.moveTo(point.x, point.y);while (t < Math.PI) {t += 0.01; // baby steps!point = to(t);context.lineTo(point.x, point.y);}context.closePath();// create the fillcontext.fillStyle = "#ea80b0";context.fill();// create the imagevar image = new Image();image.src = canvas.toDataURL();return image;})();// render that thing!function render() {// next animation framerequestAnimationFrame(render);// update timevar newTime = new Date().getTime() / 1000,deltaTime = newTime - (time || newTime);time = newTime;// clear canvascontext.clearRect(0, 0, canvas.width, canvas.height);// create new particlesvar amount = particleRate * deltaTime;for (var i = 0; i < amount; i++) {var pos = pointOnHeart(Math.PI - 2 * Math.PI * Math.random());var dir = pos.clone().length(settings.particles.velocity);particles.add(canvas.width / 2 + pos.x,canvas.height / 2 - pos.y,dir.x,-dir.y);}// update and draw particlesparticles.update(deltaTime);particles.draw(context, image);}// handle (re-)sizing of the canvasfunction onResize() {canvas.width = canvas.clientWidth;canvas.height = canvas.clientHeight;}window.onresize = onResize;// delay rendering bootstrapsetTimeout(function () {onResize();render();}, 10);})(document.getElementById("pinkboard"));
</script><script>var RENDERER = {INIT_CHERRY_BLOSSOM_COUNT: 30,MAX_ADDING_INTERVAL: 10,init: function () {this.setParameters();this.reconstructMethods();this.createCherries();this.render();if (navigator.userAgent.match(/(phone|pod|iPhone|iPod|ios|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)) {// var box = document.querySelectorAll(".box")[0];// console.log(box, "移动端");// box.style.marginTop = "65%";}},setParameters: function () {this.$container = $("#jsi-cherry-container");this.width = this.$container.width();this.height = this.$container.height();this.context = $("<canvas />").attr({ width: this.width, height: this.height }).appendTo(this.$container).get(0)var rate = this.FOCUS_POSITION / (this.z + this.FOCUS_POSITION),x = this.renderer.width / 2 + this.x * rate,y = this.renderer.height / 2 - this.y * rate;return { rate: rate, x: x, y: y };},re}} else {this.phi += Math.PI / (axis.y == this.thresholdY ? 200 : 500);this.phi %= Math.PI;}if (this.y <= -this.renderer.height * this.SURFACE_RATE) {this.x += 2;this.y = -this.renderer.height * this.SURFACE_RATE;} else {this.x += this.vx;this.y += this.vy;}return (this.z > -this.FOCUS_POSITION &&this.z < this.FAR_LIMIT &&this.x < this.renderer.width * 1.5);},};$(function () {RENDERER.init();});
</script>

5、爱心跳动.html

HTML跳动爱心特效,复制到HTML文件访问即可,效果图如下:

在这里插入图片描述

完整代码如下,复制就能用

<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta name="Keywords" content="关键字,关键词"><meta name="Description" content="描述和简介"><title>send to love</title><style type="text/css">*{margin:0;padding:0;}body,ul,li,ol,dl,dd,p,h1,h2,h3,h4,h5,h6{ margin:0;}a{text-decoration:none;color: inherit;}img{display: block;border:none;}ol,ul{list-style:none;}.clearfix:after {content: "";display: block;clear: both;}.fl{ float: left;}.fr{ float: right;}html{height: 100%;background: -webkit-radial-gradient(center,#153170,#000);}.heart{ position: relative; width: 300px; height: 300px; margin: 200px auto;transform: rotate(45deg);animation: move 2s infinite alternate ;}.heart div{ position: absolute; width: 200px; height: 200px; background: red;}.heart .middle{ right: 0; bottom: 0; width: 200px; height: 200px;}.heart .left{ left: 0; bottom: 0; border-radius: 50%;}.heart .right{ top: 0; right: 0;border-radius: 50%;}.heart p{ width: 200px; height: 30px; font: bold 25px/30px "";text-align:center; color: #fff;}.heart p{ position: absolute; right: 0; bottom: 85px; transform: rotate(-45deg);}@-webkit-keyframes move{10%{ transform: rotate(45deg) scale(1.1); text-shadow: 0 0 5px #fff; }20%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 5px #fff; }30%{ transform: rotate(45deg) scale(1.3); text-shadow: 0 0 5px #fff; }40%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 5px #fff; }50%{ transform: rotate(45deg) scale(1.3); text-shadow: 0 0 5px #fff; }60%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 5px #fff; }70%{ transform: rotate(45deg) scale(1.3); text-shadow: 0 0 5px #fff; }80%{ transform: rotate(45deg) scale(1.2); text-shadow: 0 0 10px #fff;}90%{ transform: rotate(45deg) scale(1.1); text-shadow: 0 0 5px #fff; }}</style></head><body><div class="heart"><div class="left"></div><div class="middle"></div><div class="right"></div><p>I Love You</p></div></body></html>

6、弹窗表白.py

Python弹窗表白代码,根据电脑性能设置弹窗个数,效果图如下:

在这里插入图片描述

完整代码如下,不用导入模块,复制就能用

import tkinter as tk
import random
import threading
import timedef dow():window = tk.Tk()width = window.winfo_screenwidth()height = window.winfo_screenheight()a = random.randrange(0, width)b = random.randrange(0, height)window.title('七夕快乐')  # 弹窗的名字,都可以修改的window.geometry("200x50" + "+" + str(a) + "+" + str(b))  # 弹窗大小,不建议修改tk.Label(window,text='七夕快乐!',  # 标签的文字,随便改bg='pink',  # 背景颜色font=('楷体', 17),  # 字体和字体大小width=15, height=2  # 标签长宽).pack()  # 固定窗口位置window.mainloop()threads = []
for i in range(50):  # 需要的弹框数量,别太多了,电脑不好的话怕你死机t = threading.Thread(target=dow)threads.append(t)time.sleep(0.1)threads[i].start()

7、一行代码实现心形.py

Python一行代码实现心形,效果图如下:

在这里插入图片描述

完整代码如下,复制就能用

print('\n'.join([''.join([('Love'[(x-y) % len('Love')] if ((x*0.05)**2+(y*0.1)**2-1)**3-(x*0.05)**2*(y*0.1)**3 <= 0 else ' ') for x in range(-30, 30)]) for y in range(30, -30, -1)]))

8、一箭穿心.py

Python海龟图绘制一键穿心代码,效果图如下:

在这里插入图片描述

完整代码如下,需要安装 turtle 模块

import turtle as tdef init():t.speed(2)t.pensize(2)t.screensize(480, 360)t.color('red', 'red')def draw_heart_right():t.up()t.goto(50, 50)t.pendown()t.right(45)t.goto(100, 0)t.seth(45)t.fd(120)t.circle(50, 225)def draw_heart_left():t.up()t.goto(0, 0)t.down()t.seth(45)t.fd(120)t.circle(50, 225)t.seth(90)t.circle(50, 225)t.fd(120)def draw_arrow():t.up()t.seth(0)# 羽毛t.goto(-210, 40)t.pendown()t.goto(-215, 44)t.goto(-190, 49)t.goto(-175, 46)t.up()t.goto(-210, 40)t.pendown()t.goto(-213, 34)t.goto(-185, 39)t.goto(-175, 46)t.up()# 箭杆t.pendown()t.goto(0, 80)t.penup()t.goto(160, 110)t.pendown()t.goto(320, 140)# 箭羽t.left(160)t.begin_fill()t.fd(10)t.left(120)t.fd(10)t.left(120)t.fd(10)t.end_fill()if __name__ == '__main__':init()draw_heart_right()draw_heart_left()draw_arrow()t.hideturtle()t.done()

9、爱心.py

Python海龟图绘制爱心代码,效果图如下:

在这里插入图片描述

完整代码如下,需要下载 turtle 模块

import turtle as tt.penup()
t.seth(-90)
t.fd(160)
t.pendown()
t.pensize(20)
t.colormode(255)
for j in range(10):t.speed(1000)t.pencolor(25 * j, 5 * j, 15 * j)t.seth(130)t.fd(220)for i in range(23):t.circle(-80, 10)t.seth(100)for i in range(23):t.circle(-80, 10)t.fd(220)
t.done()

10、爱心代码.py

Python海龟图绘制爱心代码,效果图如下:

在这里插入图片描述

完整代码如下,需要下载 turtlr 模块

import random
import turtle
from turtle import mainloop, hideturtle# 画心
def draw_heart(size, color_):turtle.speed(0)turtle.colormode(255)turtle.color(color_)turtle.pensize(2)turtle.pendown()turtle.setheading(150)turtle.begin_fill()turtle.fd(size)turtle.circle(size * -3.745, 45)turtle.circle(size * -1.431, 165)turtle.left(120)turtle.circle(size * -1.431, 165)turtle.circle(size * -3.745, 45)turtle.fd(size)turtle.end_fill()# 随机颜色,大小,位置
def draw():# 随机颜色colors1 = random.randint(0, 255)colors2 = random.randint(0, 255)colors3 = random.randint(0, 255)turtle.penup()# 随机位置x = random.randint(-400, 400)y = random.randint(-200, 200)turtle.goto(x, y)# 随机大小size = random.randint(10, 20)draw_heart(size, (colors1, colors2, colors3))# 主函数
def main():hideturtle()turtle.setup(900, 500)# 更改心出现的个数for i in range(30):draw()turtle.penup()turtle.goto(-200, 0)turtle.color('red')turtle.write('爱你哦', font=('宋体', 60, 'normal'))mainloop()main()

11、爱心发射.py

Python海龟图绘制爱心发射代码,效果图如下:

在这里插入图片描述

完整代码如下,需要下载 turtle 模块

import turtle
import time
from turtle import mainloop, hideturtledef clear_all():turtle.penup()turtle.goto(0, 0)turtle.color('white')turtle.pensize(800)turtle.pendown()turtle.setheading(0)turtle.fd(300)turtle.bk(600)# 重定位海龟的位置
def go_to(x, y, state):turtle.pendown() if state else turtle.penup()turtle.goto(x, y)def draw_heart(size):turtle.color('red', 'pink')turtle.pensize(2)turtle.pendown()turtle.setheading(150)turtle.begin_fill()turtle.fd(size)turtle.circle(size * -3.745, 45)turtle.circle(size * -1.431, 165)turtle.left(120)turtle.circle(size * -1.431, 165)turtle.circle(size * -3.745, 45)turtle.fd(size)turtle.end_fill()# 画出发射爱心的小人
def draw_people(x, y):turtle.penup()turtle.goto(x, y)turtle.pendown()turtle.pensize(2)turtle.color('black')turtle.setheading(0)turtle.circle(60, 360)turtle.penup()turtle.setheading(90)turtle.fd(75)turtle.setheading(180)turtle.fd(20)turtle.pensize(4)turtle.pendown()turtle.circle(2, 360)turtle.setheading(0)turtle.penup()turtle.fd(40)turtle.pensize(4)turtle.pendown()turtle.circle(-2, 360)turtle.penup()turtle.goto(x, y)turtle.setheading(-90)turtle.pendown()turtle.fd(20)turtle.setheading(0)turtle.fd(35)turtle.setheading(60)turtle.fd(10)turtle.penup()turtle.goto(x, y)turtle.setheading(-90)turtle.pendown()turtle.fd(40)turtle.setheading(0)turtle.fd(35)turtle.setheading(-60)turtle.fd(10)turtle.penup()turtle.goto(x, y)turtle.setheading(-90)turtle.pendown()turtle.fd(60)turtle.setheading(-135)turtle.fd(60)turtle.bk(60)turtle.setheading(-45)turtle.fd(30)turtle.setheading(-135)turtle.fd(35)turtle.penup()# 绘制文字
def draw_text(text, t_color, font_size, show_time):turtle.penup()turtle.goto(-350, 0)turtle.color(t_color)turtle.write(text, font=('宋体', font_size, 'normal'))time.sleep(show_time)clear_all()# 爱心发射
def draw_():turtle.speed(0)draw_people(-250, 20)turtle.penup()turtle.goto(-150, -30)draw_heart(14)turtle.penup()turtle.goto(-200, -200)turtle.color('pink')turtle.write('爱', font=('宋体', 60, 'normal'))turtle.penup()turtle.goto(-20, -60)draw_heart(25)turtle.penup()turtle.goto(-70, -200)turtle.color('pink')turtle.write('你', font=('宋体', 60, 'normal'))turtle.penup()turtle.goto(200, -100)draw_heart(45)turtle.penup()turtle.goto(150, -200)turtle.color('pink')turtle.write('哟', font=('宋体', 60, 'normal'))turtle.hideturtle()time.sleep(3)def main():# 隐藏海龟hideturtle()turtle.setup(900, 500)draw_text("准备好了吗?", "black", 60, 0)draw_text("接下来", "skyblue", 60, 0)draw_text("马上七夕,码上七夕", "pink", 60, 3)draw_()# 使用mainloop防止窗口卡死mainloop()main()

12、玫瑰花.py

Python海龟图绘制玫瑰花代码,效果图如下:

在这里插入图片描述

完整代码如下,需要下载 turtle 模块

import turtle as tdef Curve_Draw(n, r, d=1):for i in range(n):t.left(d)t.circle(r, abs(d))s = 0.2
t.setup(450 * 5 * s, 750 * 5 * s)
t.pencolor('black')
t.fillcolor('purple')
t.speed(100)
t.penup()
t.goto(0, 900 * s)
t.pendown()t.begin_fill()
t.circle(200 * s, 30)
Curve_Draw(60, 50 * s)
t.circle(200 * s, 30)
Curve_Draw(4, 100 * s)
t.circle(200 * s, 50)
Curve_Draw(50, 50 * s)
t.circle(350 * s, 65)
Curve_Draw(40, 70 * s)
t.circle(150 * s, 50)
Curve_Draw(20, 50 * s, -1)
t.circle(400 * s, 60)
Curve_Draw(18, 50 * s)
t.fd(250 * s)
t.right(150)
t.circle(-500 * s, 12)
t.left(140)
t.circle(550 * s, 110)
t.left(27)
t.circle(650 * s, 100)
t.left(130)
t.circle(-300 * s, 20)
t.right(123)
t.circle(220 * s, 57)
t.end_fill()t.left(120)
t.fd(280 * s)
t.left(115)
t.circle(300 * s, 33)
t.left(180)
t.circle(-300 * s, 33)
Curve_Draw(70, 225 * s, -1)
t.circle(350 * s, 104)
t.left(90)
t.circle(200 * s, 105)
t.circle(-500 * s, 63)
t.penup()
t.goto(170 * s, -30 * s)
t.pendown()
t.left(160)
Curve_Draw(20, 2500 * s)
Curve_Draw(220, 250 * s, -1)t.fillcolor('green')
t.penup()
t.goto(670 * s, -180 * s)
t.pendown()
t.right(140)
t.begin_fill()
t.circle(300 * s, 120)
t.left(60)
t.circle(300 * s, 120)
t.end_fill()
t.penup()
t.goto(180 * s, -550 * s)
t.pendown()
t.right(85)
t.circle(600 * s, 40)t.penup()
t.goto(-150 * s, -1000 * s)
t.pendown()
t.begin_fill()
t.rt(120)
t.circle(300 * s, 115)
t.left(75)
t.circle(300 * s, 100)
t.end_fill()
t.penup()
t.goto(430 * s, -1070 * s)
t.pendown()
t.right(30)
t.circle(-600 * s, 35)
t.done()

粉丝福利

评论区浏览即可参与抽奖,送《CISSP信息系统安全专家认证All-in-One》三本。

《CISSP信息系统安全专家认证All-in-One(第9版)》针对发布的CISSP考试做了全面细致的修订和更新,涵盖(ISC)2新开发的2021 CISSP考试大纲的所有目标。这本综合性指南编排精当,每章开头列出学习目标,正文中穿插考试提示,章末附有练习题和精辟解释。本书由**的IT安全认证和培训专家撰写,将帮助你轻松通过考试;也可作为你工作中的一本重要参考书。

在这里插入图片描述

更多详情可参考链接 http://www.tup.tsinghua.edu.cn/booksCenter/book_09671701.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/108137.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

<八> objectARX开发:动态拖动Jig创建自定义实体

1、介绍 接上一篇文章,在某些情况下,CAD中的实体对象初始参数并不是固定的,我们需要通过jig动态拖动方式来绘制自定义实体,下面就用一个简单的例子来介绍一下自定义实体动态绘制。   实体形状:包括实体夹点和文字夹点拖动实现。 2、效果 3、源码 static void RYMyGrou…

CAN总线学习——物理层、数据链路层、CANopen协议

1、CAN总线介绍 1.1、CAN总线描述 (1)CAN总线支持多节点通信&#xff0c;但是节点不分区主从&#xff0c;也就是不存在一个节点来负责维护总线的通信&#xff1b;这点可以和I2C总线对对比&#xff0c;I2C是一主多从模式&#xff1b; (2)是差分、异步、串行总线&#xff0c;采用…

华为OD机试 - 求满足条件的最长子串的长度 - 双指针(Java 2023 B卷 100分)

目录 专栏导读一、题目描述二、输入描述三、输出描述四、解题思路五、Java算法源码六、效果展示1、输入2、输出3、说明 华为OD机试 2023B卷题库疯狂收录中&#xff0c;刷题点这里 专栏导读 本专栏收录于《华为OD机试&#xff08;JAVA&#xff09;真题&#xff08;A卷B卷&#…

无人驾驶领域的软件测试该如何开展?

无人驾驶汽车使用自主决策和控制系统&#xff0c;这种系统通常由多个软件和硬件组件组成。软件测试是必要的&#xff0c;因为它可以确保无人驾驶汽车的软件系统达到高度可靠性和安全性&#xff0c;以及提高无人驾驶汽车的性能和可靠性。 因此无人驾驶汽车是一定要进行严格的软件…

关于类的隐形生成函数

https://www.youtube.com/watch?ve8Cw17p_BiU&listPL5jc9xFGsL8FWtnZBeTqZBbniyw0uHyaH&index6 https://www.youtube.com/watch?vKMSYmY74AEs&listPLE28375D4AC946CC3&index4 如果只有copy asignment operator, 那么default construct will be generated as…

PyCharm软件安装包分享(附安装教程)

目录 一、软件简介 二、软件下载 一、软件简介 PyCharm是一种集成开发环境&#xff08;IDE&#xff09;&#xff0c;专门为Python开发者设计。它是由捷克软件公司JetBrains开发的&#xff0c;为Python开发人员提供了高效、易用和功能丰富的工具集。 以下是PyCharm软件的主要…

【C语言】操作符大全(保姆级介绍)

&#x1f6a9;纸上得来终觉浅&#xff0c; 绝知此事要躬行。 &#x1f31f;主页&#xff1a;June-Frost &#x1f680;专栏&#xff1a;C语言 &#x1f525;该篇将详细介绍各种操作符的功能。 目录&#xff1a; &#x1f4d8; 前言① 算术操作符②移位操作符③位操作符④赋值操…

JS-this知识点、面试题

一、this指向什么 1.简介 2.规则一&#xff1a;默认绑定 3.规则二&#xff1a;隐式绑定 4.规则四&#xff1a;new绑定 5.规则三&#xff1a;显式绑定 call、apply、bind 6.内置函数的绑定 7.规则优先级 8.this规则之外--es6剪头函数 9.ES6剪头函数this 二、This面试题 面试题…

解决Spring Boot项目中pom.xml环境配置 打包后生效 但idea版本运行无效的问题

上文 Spring Boot中通过maven进行多环境配置 中我们通过pom.xml配置了环境选择 但这个只有在打包出来的jar中生效 我们直接通过 idea启动 这个东西确实是有点问题 其实 我们执行一下 compile 手工编译一下 然后重新启动 很明显 我们这里配置就已经生效了 这个就是 我们每次…

成功解决SQL 错误 [22000]: 第3 行附近出现错误: 试图修改自增列[ID](达梦数据库)

当我们使用工具来手动修改自增列的自增ID时&#xff0c;可能会报如下异常 SQL 错误 [22000]: 第3 行附近出现错误:试图修改自增列[ID] 解决办法&#xff1a; 可以使用SQL语句来修改 ALTER TABLE "fdw"."SYSTEM_DICT_TYPE" DROP IDENTITY; UPDATE "f…

【python】python智能停车场数据分析(代码+数据集)【独一无二】

&#x1f449;博__主&#x1f448;&#xff1a;米码收割机 &#x1f449;技__能&#x1f448;&#xff1a;C/Python语言 &#x1f449;公众号&#x1f448;&#xff1a;测试开发自动化【获取源码商业合作】 &#x1f449;荣__誉&#x1f448;&#xff1a;阿里云博客专家博主、5…

LeetCode-738-单调递增的数字

题目描述&#xff1a; 当且仅当每个相邻位数上的数字 x 和 y 满足 x < y 时&#xff0c;我们称这个整数是单调递增的。 给定一个整数 n &#xff0c;返回 小于或等于 n 的最大数字&#xff0c;且数字呈 单调递增 。 解题思路&#xff1a; 先将int变成char[]&#xff0c;获取…

【JavaEE】Spring事务-@Transactional参数介绍-事务的隔离级别以及传播机制

【JavaEE】Spring事务&#xff08;2&#xff09; 文章目录 【JavaEE】Spring事务&#xff08;2&#xff09;1. Transactional 参数介绍1.1 value 和 transactionManager1.2 timeout1.3 readOnly1.4 后面四个1.5 isolation 与 propagation 2. Spring 事务隔离级别 - isolation2.…

Git入门

本文主要介绍Git的入门知识。首先讲述版本控制工具的一些背景&#xff0c; 然后介绍如何在你自己的系统上安装.配置和运行Git。学完本文,你将明白Git是怎么来的、为什么需要Git,并掌握使用Git的基础知识。 一、版本控制 什么是“版本控制”&#xff0c;为什么需要它?版本控制是…

5G NR:PRACH时域资源

PRACH occasion时域位置由高层参数RACH-ConfigGeneric->prach-ConfigurationIndex指示&#xff0c;根据小区不同的频域和模式&#xff0c;38.211的第6.3.3节中给出了prach-ConfigurationIndex所对应的表格。 小区频段为FR1&#xff0c;FDD模式(paired频谱)/SUL&#xff0c;…

RHCE——八、DNS域名解析服务器

RHCE 一、概述1、产生原因2、作用3、连接方式4、因特网的域名结构4.1 拓扑4.2 分类4.3 域名服务器类型划分 二、DNS域名解析过程1、分类2、解析图&#xff1a;2.1 图&#xff1a;2.2 过程分析 三、搭建DNS域名解析服务器1、概述2、安装软件3、/bind服务中三个关键文件4、配置文…

什么是 API ?

一、API 的定义&#xff1a;数据共享模式定义 4 大种类 作为互联网从业人员&#xff0c;API 这个词我耳朵都听起茧子了&#xff0c;那么 API 究竟是什么呢&#xff1f; API 即应用程序接口&#xff08;API&#xff1a;Application Program Interface&#xff09;&#xff0c;…

基于YOLOV8模型的课堂场景下人脸目标检测系统(PyTorch+Pyside6+YOLOv8模型)

摘要&#xff1a;基于YOLOV8模型的课堂场景下人脸目标检测系统可用于日常生活中检测与定位课堂场景下人脸&#xff0c;利用深度学习算法可实现图片、视频、摄像头等方式的目标检测&#xff0c;另外本系统还支持图片、视频等格式的结果可视化与结果导出。本系统采用YOLOv8目标检…

c#设计模式-创建型模式 之 原型模式

概述 原型模式是一种创建型设计模式&#xff0c;它允许你复制已有对象&#xff0c;而无需使代码依赖它们所属的类。新的对象可以通过原型模式对已有对象进行复制来获得&#xff0c;而不是每次都重新创建。 原型模式包含如下角色&#xff1a; 抽象原型类&#xff1a;规定了具…

基于微信小程序的垃圾分类系统设计与实现(2.0 版本,附前后端代码)

博主介绍&#xff1a;✌程序员徐师兄、7年大厂程序员经历。全网粉丝30W、csdn博客专家、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ 1 简介 视频演示地址&#xff1a; 基于微信小程序的智能垃圾分类回收系统&#xff0c;可作为毕业设计 小…