随笔 - 23  文章 - 0  评论 - 0  阅读 - 11594
01 2023 档案
python 关于类class的相关练习代码:狗类、具体人的对象、小明爱跑步、设计一个circle圆类、猫类抓鼠类
摘要:class Dog(): def __init__(self,D_breed,D_name,D_age,D_gender): self.breed=D_breed self.name=D_name self.age=D_age self.gender=D_gender def look_home(s 阅读全文
posted @ 2023-01-10 20:29 至清无物 阅读(190) 评论(0) 推荐(0) 编辑
python简易计算器的实现
摘要:#导入模块 import datetime,time,tkinter #新建一个窗口 windows=tkinter.Tk() #给窗口定义标题 windows.title('简易计算器') #给窗口定义尺寸 windows.geometry('500x600') # 逻辑事件 content='' 阅读全文
posted @ 2023-01-09 21:16 至清无物 阅读(109) 评论(0) 推荐(0) 编辑
python 解决数学相关问题 实现代码
摘要:#题目:纸厚0.08mm,折几次可以达到珠穆朗玛峰8848.13米的高度 m_height=8848.13*1000 z_height=oldz_height=0.08 #计数器 count=0 #利用循环方法1: while z_height<m_height: z_height*=2 count 阅读全文
posted @ 2023-01-09 16:33 至清无物 阅读(366) 评论(0) 推荐(0) 编辑
python 数学题 百元百鸡 百马百担 实现代码
摘要:#母鸡三元一只,公鸡一元一只,小鸡0.5元一只,一百元全部买鸡,有多少种不同买法,分别是什么? count=0 for m_j in range(1,100//3): for g_j in range(1,100): for x_j in range(2,101,2): if(m_j+g_j+x_j 阅读全文
posted @ 2023-01-09 16:31 至清无物 阅读(682) 评论(0) 推荐(0) 编辑
python小游戏——输入一个数字,是否和随机数字相同
摘要:import tkinter,random,tkinter.messagebox #创建窗口 window=tkinter.Tk() #设置窗口大小 window.geometry('500x500') #设置窗口标题 window.title('猜字游戏界面') # 数据逻辑 good_price 阅读全文
posted @ 2023-01-09 16:28 至清无物 阅读(525) 评论(0) 推荐(0) 编辑
python学习-PTL图片-pillow相关代码
摘要:# 引用PTL图片 from PIL import Image # 打开图片 image=Image.open('./image/1.JPG') # 打印图片 print(image) # 显示图片image.show() # 打印图片的尺寸、模式、具体信息、格式化信息 print(image.si 阅读全文
posted @ 2023-01-08 20:21 至清无物 阅读(213) 评论(0) 推荐(0) 编辑
python打印乘法口诀、加法口诀、减法口诀,复制到EXCEL直接打印
摘要:# 乘法口诀 for x in range(1,10): for y in range(1,x+1): print(f'{y}x{x}={x*y}', end='\t') print() print('\n') # 加法口诀 for x in range(1,10): for y in range( 阅读全文
posted @ 2023-01-08 20:17 至清无物 阅读(742) 评论(0) 推荐(0) 编辑
python获取随机三位数是水仙花数
摘要:#求随机三个数是水仙花数 num=random.randint(100,999) hundred=num // 100 decade=num % 100 // 10 ones=num % 10 if hundred ** 3 +decade ** 3 +ones ** 3 == num: print 阅读全文
posted @ 2023-01-08 20:12 至清无物 阅读(145) 评论(0) 推荐(0) 编辑
python判断随机年份是否为平年或者闰年,同时求的每个月的天数
摘要:#求闰年和平年 year=random.randint(1900,2023) if (year % 4 ==0 and year % 100 !=0) or (year % 400 ==0): print(f'{year}年是百年一遇的闰年,顺顺利利') else: print(f'现在是{year 阅读全文
posted @ 2023-01-08 20:05 至清无物 阅读(221) 评论(0) 推荐(0) 编辑
Python学习——random相关代码
摘要:import random #求随机能被3和5同时整除的数 num=random.randint(1,1000) if num % 3==0 and num % 5 ==0: print(f'数字{num}可以被3和5整除') elif num % 3 ==0: print(f'数字{num}可以被 阅读全文
posted @ 2023-01-08 20:04 至清无物 阅读(116) 评论(0) 推荐(0) 编辑
Python小游戏(1)
摘要:name=str(input('请输入姓名:')) age=int(input('请输入真实年龄:')) if age >= 18 : print(f'恭喜{name}可以在网上冲浪了。') else: print('小小年纪不学好,赶紧回家写作业去!') money=float(input('嘴巴 阅读全文
posted @ 2023-01-08 19:55 至清无物 阅读(37) 评论(0) 推荐(0) 编辑
Python如果利用海龟turtle来绘制奥运五环
摘要:#导入工具 import turtle #奥运五环 turtle.screensize(800,800) turtle.pensize(10) #中间黑色的圆 turtle.pencolor('black') turtle.circle(100) #左边蓝色的圆 turtle.penup() tur 阅读全文
posted @ 2023-01-08 19:19 至清无物 阅读(388) 评论(0) 推荐(0) 编辑
Python海龟绘画制图的相关代码
摘要:#导入工具 # import turtle #定义一个画布尺寸的两种方式 turtle.screensize(100,100) turtle.setup(800,600,700,200) #定义画笔 turtle.shape('turtle') #定义画笔颜色 turtle.pencolor('bl 阅读全文
posted @ 2023-01-08 19:12 至清无物 阅读(1813) 评论(0) 推荐(0) 编辑
Python根据总秒数求的具体的时分秒
摘要:time=15678 hour=time//3600 minute=time%3600//60 second=time%60 print(hour,'时',minute,'分',second,'秒') 4 时 21 分 18 秒 阅读全文
posted @ 2023-01-08 19:01 至清无物 阅读(150) 评论(0) 推荐(0) 编辑
Python如何实现两个数值的交换
摘要:a=10 b=20 a=a^b b=a^b a=a^b print(a,b) 返回 20 10 阅读全文
posted @ 2023-01-08 19:01 至清无物 阅读(90) 评论(0) 推荐(0) 编辑
【Python】如何获取字符的十进制数值
摘要:print(ord('y'),',',ord('a')) 121 , 97 阅读全文
posted @ 2023-01-08 18:59 至清无物 阅读(21) 评论(0) 推荐(0) 编辑
【Python】算数运算符的区别
摘要:# 算数运算符的区别 # 数值+布尔真为1假为0 print(1+True) # 在字符串里面+作为连接符使用 print('你'+'好'+'!') # 在字符串里面用乘号,输入该字符串三次 print('您好\n'*3) # 幂运算为前一个数的后一个数次方 print(2**3) # 除 # pr 阅读全文
posted @ 2023-01-08 18:43 至清无物 阅读(15) 评论(0) 推荐(0) 编辑
【Python】输入并查看数据类型
摘要:print(type(1)) 返回 int print(type('您好')) 返回 str 字符串 print(type(0>1)) 返回 bool 布尔类型 print(type(3.145)) 返回 float 浮点类型 print(type(1))# 返回 int print(type('您 阅读全文
posted @ 2023-01-08 18:40 至清无物 阅读(167) 评论(0) 推荐(0) 编辑
【Python】SystemError: tile cannot extend outside image:【PIL Image crop()】
摘要:# 图片裁剪,需要设置边缘间距【left,upper,right,lower】 image_5=image.crop(box=(1000,1000,1000,1000)) image_5.show() 出现错误 SystemError: tile cannot extend outside imag 阅读全文
posted @ 2023-01-08 11:01 至清无物 阅读(796) 评论(0) 推荐(0) 编辑
【Python】TypeError: integer argument expected, got float【‘/’与'//'的区别】
摘要:运行如下代码:突然出现错误。 from PIL import Image image=Image.open('./image/3.JPG') print(image) image_1=image.resize((1000,1000)) image_2=image.resize((image.size 阅读全文
posted @ 2023-01-08 10:08 至清无物 阅读(1363) 评论(0) 推荐(0) 编辑
pip的相关指令
摘要:pip install 安装包 表示安装指定的第三方安装包 pip uninstall 卸载安装包 表示卸载指定的第三方安装包 pip list 显示已经安装的安装包,比如版本信息等 这些命令都可以再命令窗口运行。 阅读全文
posted @ 2023-01-07 22:31 至清无物 阅读(29) 评论(0) 推荐(0) 编辑
【Python】pip的镜像安装异常解决方案
摘要:在安装pip的出现异常提示: ERROR: Could not find a version that satisfies the requirement pillow (from versions: none) ERROR: No matching distribution found for p 阅读全文
posted @ 2023-01-07 22:22 至清无物 阅读(1121) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示