新学python画一个爱心
程序简略代码如下:
from turtle import *
def curvemove():
for i in range(200):
right(1)
forward(1)
color('yellow','red')
begin_fill()
left(140)
forward(111.65)
curvemove()
left(120)
curvemove()
forward(111.65)
end_fill()
done()
输出图片如下:

用pyinstaller将上述程序打包得到的可执行文件可以在没有安装python环境下执行。
方法如下:
cmd下安装pyinstaller库
pip install pyinstaller
然后找到上述代码的文件目录,例如:C:\Users\Benny\Desktop\Python\Python练习\heart_shaped_picture.py
在cmd下相继执行下列语句:
pyinstaller C:\Users\Benny\Desktop\Python\Python练习\heart_shaped_picture
pyinstaller -F C:\Users\Benny\Desktop\Python\Python练习
命令执行会在根目录下生成两个文件夹build和dist,build记录一些日志log,heart_shaped_picture.exe生成在dist文件夹内。
如果上述代码运行结束时出现PermissionError:不用理会。
新学python画一个爱心的更多相关文章
- 如何利用Python绘制一个爱心
刚学习Python几周,闲来无事,突然想尝试画一个爱心,步骤如下: 打开界面 打开Python shell界面,具体是Python语言的IDLE软件脚本. 2.建立脚本 单击左上角’File’,再单击 ...
- 用Turtle库画一个爱心
---恢复内容开始--- 用Python中的turtle库画一个爱心 这个学期,我学了Python语言,并学到其中的一个库:turtle库.用turtle库可以画一些你想画的图片,所以我就想画一个爱心 ...
- 程序猿的浪漫:用python画动态爱心
初级画心 学Python,感觉你们的都好复杂,那我来个简单的,我是直接把心形看作是一个正方形+两个半圆:
- Python画一个四点连线并计算首尾距离
import turtle import math #先定义4个坐标 x1,y1=100,100 x2,y2=100,-100 x3,y3=-100,-100 x4,y4=-100,100 #然后 ...
- 使用Python画一个带坐标轴的圆
Download Microsoft Visual Studio Microsoft Visual Studio enables you develop your python Application ...
- 如何用Python画一个圣诞树呢?
# ./sd.py * *** ***** ******* ********* |[root@bogon shengdan]# vim sd.py[root@bogon shengdan]# cat ...
- 用C语言画一个“爱心”
/*每个main函数代表一种形状*/#include<iostream> using namespace std; #include<stdio.h> #include< ...
- 小记:xml画一个爱心。
aixin.xml: <!-- height:width=viewportHeight:viewportWidth --> <vector xmlns:android=" ...
- 用Python画一个八角形代码示例
import turtle turtle.color("purple","yellow") turtle.speed(1) turtle.fd(100) t ...
随机推荐
- submit提交判断
body部分 <form action='https://www.baidu.com' method='post' > 用 户 名:<input ...
- zxing生成二维码和条码
/*** * 生成二维码方法 * @param str 生成内容 * @param widthHeight 宽度和高度 * @return * @throws WriterException */ p ...
- [UE4]用Format Text进行调试
{姓名},在{时间}进来了 “{姓名}”和“{时间}”会自动变成一个变量.
- Python解释器的安装
Python解释器的安装 作者:Eric 微信:loveoracle11g 下载Python Python-3.7.0(64-bit)下载链接地址: https://www.python.org/ft ...
- Oracle数据库自带表空间的详细说明
1.SYSAUX表空间 SYSAUX表空间在Oracle Database 10g中引入,作为SYSTEM表空间的辅助表空间.以前一些使用独立表空间或系统表空间的数据库组件现在在SYSAUX表空间中创 ...
- Vue ElementUI 按需引入
一.element UI组件的单独使用(第一种方法): 1.cnpm install babel-plugin-component -D 2.找到.babelrc 配置文件 ...
- Android给控件添加默认点击效果
Android控件点击效果 Android中Button控件是有点击效果的,但是像TextView.ImageView.各种Layout是没有点击效果的,给TextView设置点击事件后,加个点击效果 ...
- python-封装方法用于读取excel
1.实现获取excel某张表的行数.单元格数据 #coding=utf-8 import xlrd #获取excel文件 data = xlrd.open_workbook('file_path/xx ...
- LeetCode 106. Construct Binary Tree from Inorder and Postorder Traversal 由中序和后序遍历建立二叉树 C++
Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that ...
- 基于前台vue,后台是spring boot的压缩图片上传
本人是刚毕业的新手,最近公司的一个项目,前后端分离,前端Vue,后端使用spring boot.其中有一个需求是需要做前端上传的图片需要压缩才能上传.为此在网上查找资料,并做了简单的实现. 那么一步来 ...