用python的turtle模块实现给女票画个小心心


Posted in Python onNovember 23, 2019

晚上自习无聊

正好拿自己的平板电脑用python写了个小程序,运用turtle模块画一个小心心,并在心上画女票名字的首字母缩写,单纯只为红颜一笑。

代码贴出来,很简单

import turtle
import time
def liujia():
 for i in range (200):
 turtle.right(1)
 turtle.forward(1)
turtle.color('red','pink')
turtle.pensize(2)
turtle.speed(10)
turtle.goto(0,0)

turtle.begin_fill()
turtle.left(140)
turtle.forward(112)
liujia()
turtle.left(120)
liujia()
turtle.forward(112)
turtle.end_fill()
turtle.pensize(5)
turtle.up()
turtle.goto(-50,142.7)
turtle.left(50)
turtle.down()
turtle.forward(60)
turtle.left(90)
turtle.forward(25)
turtle.up()
turtle.goto(37.5,142.7)
turtle.down()
turtle.forward(25)
turtle.up()
turtle.goto(50,142.7)
turtle.right(90)
turtle.down()
turtle.forward(60)
for i in range (20):
 turtle.right(7.8)
 turtle.forward(0.3)
turtle.forward(8)
turtle.up()
turtle.goto(100,-10)
turtle.write("I Love you")

用python的turtle模块实现给女票画个小心心

虽然丑丑的,但是她笑了啊

代码这样应该好理解了吧,各位老铁,不要再问怎么改名字了,网上学一下turtle库怎么使用,很简单的

import turtle
import time
Name=['L','J']
def draw_circle():
  for i in range (200):
    turtle.right(1)
    turtle.forward(1)
def draw_love():
  turtle.color('red','pink')
  turtle.pensize(2)
  turtle.speed(1000)
  turtle.goto(0,0)
  turtle.begin_fill()
  turtle.left(140)
  turtle.forward(112)
  draw_circle()
  turtle.left(120)
  draw_circle()
  turtle.forward(112)
  turtle.end_fill()
def draw_name():
  turtle.pensize(5)
  turtle.up()
  turtle.goto(-50,142.7)
  if Name[0]=='L':
    turtle.left(50)
    turtle.down()
    turtle.forward(60)
    turtle.left(90)
    turtle.forward(25)
  turtle.up()
  turtle.goto(37.5,142.7)
  if Name[1]=='J':
    turtle.down()
    turtle.forward(25)
    turtle.up()
    turtle.goto(50,142.7)
    turtle.right(90)
    turtle.down()
    turtle.forward(60)
    for i in range (20):
      turtle.right(7.8)
      turtle.forward(0.3)
    turtle.forward(8)
    turtle.up()
  turtle.goto(100,-10)
  turtle.write("I Love you")


draw_love()
draw_name()

以上这篇用python的turtle模块实现给女票画个小心心就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
详解Python的Django框架中的模版继承
Jul 16 Python
Python爬虫框架Scrapy实例代码
Mar 04 Python
Pandas 对Dataframe结构排序的实现方法
Apr 10 Python
Python二叉树定义与遍历方法实例分析
May 25 Python
解决Tensorflow使用pip安装后没有model目录的问题
Jun 13 Python
python中将\\uxxxx转换为Unicode字符串的方法
Sep 06 Python
使用Python如何测试InnoDB与MyISAM的读写性能
Sep 18 Python
Python使用Turtle库绘制一棵西兰花
Nov 23 Python
python爬虫开发之使用python爬虫库requests,urllib与今日头条搜索功能爬取搜索内容实例
Mar 10 Python
sublime3之内网安装python插件Anaconda的流程
Nov 10 Python
python爬取股票最新数据并用excel绘制树状图的示例
Mar 01 Python
Python+Matplotlib+LaTeX玩转数学公式
Feb 24 Python
python 利用turtle库绘制笑脸和哭脸的例子
Nov 23 #Python
Python使用Turtle库绘制一棵西兰花
Nov 23 #Python
用Python实现校园通知更新提醒功能
Nov 23 #Python
利用Python的turtle库绘制玫瑰教程
Nov 23 #Python
Python input函数使用实例解析
Nov 22 #Python
python循环输出三角形图案的例子
Nov 22 #Python
Python-Flask:动态创建表的示例详解
Nov 22 #Python
You might like
1982年日本摄影师镜头下的中国孩子 那无忧无虑的童年
2020/03/12 杂记
56.com视频采集接口程序(PHP)
2007/09/22 PHP
PHP 使用header函数设置HTTP头的示例解析 表头
2013/06/17 PHP
session在php5.3中的变化 session_is_registered() is deprecated in
2013/11/12 PHP
PHP的Laravel框架中使用AdminLTE模板来编写网站后台界面
2016/03/21 PHP
form自动提交实例讲解
2017/07/10 PHP
PHP框架实现WebSocket在线聊天通讯系统
2019/11/21 PHP
javascript倒计时功能实现代码
2012/06/07 Javascript
javascript中的void运算符语法及使用介绍
2013/03/10 Javascript
详解jquery中$.ajax方法提交表单
2014/11/03 Javascript
jQuery采用连缀写法实现的折叠菜单效果
2015/09/18 Javascript
JavaScript判断用户名和密码不能为空的实现代码
2016/05/16 Javascript
基于JavaScript实现瀑布流效果
2017/03/29 Javascript
node的process以及child_process模块学习笔记
2018/03/06 Javascript
更改BootStrap popover的默认样式及popover简单用法
2018/09/13 Javascript
小程序云函数调用API接口的方法
2019/05/17 Javascript
解决Idea、WebStorm下使用Vue cli脚手架项目无法使用Webpack别名的问题
2019/10/11 Javascript
浅谈使用nodejs搭建web服务器的过程
2020/07/20 NodeJs
python查找指定具有相同内容文件的方法
2015/06/28 Python
Python selenium 父子、兄弟、相邻节点定位方式详解
2016/09/15 Python
python递归函数绘制分形树的方法
2018/06/22 Python
Python在Matplotlib图中显示中文字体的操作方法
2019/07/29 Python
Python的形参和实参使用方式
2019/12/24 Python
css3实现简单的白云飘动背景特效
2020/10/28 HTML / CSS
英国运动风奢侈品购物网站:Maison De Fashion
2020/08/28 全球购物
写出SQL四条最基本的数据操作语句(DML)
2012/12/12 面试题
值传递还是引用传递
2015/02/08 面试题
J2EE包括哪些技术
2016/11/25 面试题
村捐赠仪式答谢词
2014/01/21 职场文书
生产部管理制度
2014/01/31 职场文书
财务负责人任命书
2014/06/06 职场文书
家装业务员岗位职责
2015/04/03 职场文书
社区党务工作总结2015
2015/05/19 职场文书
关于法制教育的宣传语
2015/07/13 职场文书
mysql中between的边界,范围说明
2021/06/08 MySQL
解决使用了nginx获取IP地址都是127.0.0.1 的问题
2021/09/25 Servers