- 博客(19)
- 收藏
- 关注
原创 虎年春联小解
虎年将近,先提前祝各位码神新年快乐!!!新的一年天天开心,阖家欢乐不过过年归过年,咱家的手艺活不能丢,所以也是综合了一下用PY来写对联的快乐。主要的库应用1.pillow库2.numpy库3.requests库代码如下:import iofrom PIL import Imageimport numpy as npimport requestsdef get_word(ch, quality): """获取单个汉字(字符)的图片 ch ...
2022-01-21 19:28:51 2276
原创 扇形图(圆盘)matplotlib
import matplotlib.pyplot as plt (采用的matplotlib数据库)labels='IPHONE13PRO','XiaoMi12','HONOR60pro','SAMSUNGs21' (定义变量名称)size=[44,29,36,17] ...
2022-01-15 23:13:16 967
原创 绘制三角函数(matplotlib数据库)
import numpy as npimport matplotlib.pyplot as pltdef f(t): return np.exp(-t)*np.cos(2*np.pi*t)a=np.arange(0,5,0.02)plt.subplot(332)plt.plot(a,f(a))plt.subplot(333)plt.plot(a,np.cos(2*np.pi*a),'-.',color='r') (余弦函数)plt.subplot(334)plt.p...
2022-01-13 23:18:38 1560
原创 PY爬取网站信息页
import requests :导入库 r=requests.get('url'): 发送并返回请求资源 例子:r=requests.get('www.4399.com') print(r.status_code):查看状态码(是否发送成功) r.encoding:产看网页编码 r.apparent_encoding:根据网页内容评估的备用编码 r.text:查看整个网页的内容这边可以双击点开黄色文字区域(最好不要随意点开行数多的,亲身实践3060电脑都...
2021-12-23 23:12:33 678
原创 PY爬取图片
重点代码import requests#找到想要的图片的图片地址url='https://i01piccdn.sogoucdn.com/d5fe5a65b5947c98'#选择想要保存的文件目录及图片名path='..//picture/程序员.jpg'try: r=requests.get(url)#写入二进制文件#这里面选择保存的格式,b为二进制 f=open(path,'wb') f.write(r.content) f....
2021-12-23 22:23:09 2030
原创 圣诞树。程序员也有小浪漫~
from turtle import *import timesetup(500, 500, startx=None, starty=None)speed(0)pencolor("green")pensize(10)penup()hideturtle()goto(0, 150)showturtle()pendown()shape(name="classic")seth(-120)for i in range(10): fd(12) right(2)penup()...
2021-12-23 12:35:19 312
原创 九九乘法口诀
1、九九乘法口诀,for引导for a in range(1,10): for b in range(1,a+1): print('{}*{}'.format(b,a,a*b),end="\t") print("\n")2、while引导
2021-12-17 14:49:22 72
原创 文件的写入与读取
将Stu_pack的‘万疆.txt’写入demo里面’副本_万疆.txt')fr=open('../Stu_pack\万疆.txt','rt',encoding='utf_8')fw=open('副本_万疆.txt','w+',encoding='utf_8')for line in fr: fw.write(line)fr.close()fw.close()
2021-12-17 14:47:34 59
原创 爱心的快乐源泉
from turtle import *def curvemove(): for i in range(200): right(1) forward(1)color('red') begin_fill()left(140)forward(111.65)curvemove()left(120)curvemove()forward(111.65)end_fill()done()
2021-12-10 17:15:01 174
原创 【无标题】纪念20211202的彩色七段管试图
import turtle as timport random as r #导入随机库import time #导入时间库#定义绘制线段函数:def drawLine(draw): t.pendown() if draw else t.penup() t.pencolor(r.random(),r.random(),r.random()) t.fd(80) t.right(90)#定义绘制0——9数字函数:def draw...
2021-12-02 21:13:36 90
原创 七段管表达日期
from turtle import *from time import *def drawLine(draw): pendown() if draw else penup() fd(80) right(90)def drawDigit(i): drawLine(True) if i in [2,3,4,5,6,8,9] else drawLine(False) drawLine(True) if i in [0,1,3,4,5,6,7,8,9] else...
2021-11-30 20:57:35 85
原创 数字七段管
from turtle import *pensize(5)pencolor('blue')fd(80)right(90)fd(80)right(90)fd(90)right(90)fd(80)fd(80)right(90)fd(90)right(90)fd(80)right(90)hideturtle()done()def drawLine(draw): pendown() if draw else penup() fd(80) right.
2021-11-30 20:51:44 73
原创 联系人簿简易版
制作的简易版储存联系人person=dict()i=0while i<100: a=int(input("请输入您要操作的菜单的数字:")) if a==1: print("添加联系人") name=input("请输入联系人的姓名:") number=input("请输入联系人的电话:") person[name]=number print("联系人已成功保存到通讯录!!!") if a
2021-11-22 22:41:41 194
原创 能被2或3整除的数.py
a=int(input('请输入起点(整数):'))b=int(input('请输入终点(整数):'))if a>b: print('输入错误,请重新输入!')print('在{}和{}之间能被2或3整除的数有:'.format(a,b))for i in range(a,b+1): if i%3==0 or i%2==0: print('{}'.format(i),end=',')print('')...
2021-11-19 18:01:40 735
原创 TemptConvert.py
#TemptConvert.py(温度的转化)#I(input):输入数据TempStr=input('请输入带符号的温度值:')#P(process):数据处理器if TempStr[-1] in ['F','f']: C=(float(TempStr[0:-1])-32)/1.8 print('转化后的温度值为:{:.2f}C'.format(C))elif TempStr[-1] in ['C','c']: F=float(TempStr[0:-1])*1.8+...
2021-10-24 15:52:24 2004
原创 the sun PY
#SUN.pyfrom turtle import *pensize(5)color('yellow','red')begin_fill()for i in range(10): fd(200) right(-72) left(36)end_fill()
2021-10-24 15:46:07 65
原创 root by wcx
#gen.py(求根)#I(input):输入数据a=input('请输入a的值:')b=input('请输入b的值:')c=input('请输入c的值:')a=float(a)b=float(b)c=float(c)d=b**2-4*a*c>0float(d)#P(process):处理数据if d>0: x=(-b+d**0.5)/(2*a) x=float(x) f=(-b-d**0.5)/(2*a) f=float(f) print('...
2021-10-24 15:37:05 2267
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人