摘要: 1 from turtle import * 2 3 def square(size=50, rgb='orange'): 4 '''绘制正方形 5 参数size指定边长 6 参数rgb指定画笔颜色 7 如果没有给参数,采用默认值 8 ''' 9 pencolor(rgb) 10 for i in 阅读全文
posted @ 2022-06-14 10:43 pray4hell 阅读(5) 评论(1) 推荐(0) 编辑
摘要: 1 class user: 2 def __init__(self,name='guest',password=111111,status=1): 3 self.name = name 4 self.password = password 5 self.status = status 6 7 def 阅读全文
posted @ 2022-06-08 13:13 pray4hell 阅读(3) 评论(2) 推荐(0) 编辑
摘要: 1 def v(x): 2 z=0 3 if len(x)!=18: 4 return False 5 else: 6 for i in x: 7 if ord(i) < 48 or 87>=ord(i)>57 or ord(i)>88: 8 z+=1 9 if z!=0: 10 return Fa 阅读全文
posted @ 2022-05-22 10:41 pray4hell 阅读(9) 评论(3) 推荐(0) 编辑
摘要: 1 with open ('data3.txt','r',encoding='utf-8')as f: 2 a=f.readlines() 3 del a[0] 4 b=[] 5 c=[] 6 for i in a: 7 if float(i.replace('\n',''))-int(float( 阅读全文
posted @ 2022-05-17 12:37 pray4hell 阅读(6) 评论(3) 推荐(0) 编辑
摘要: 1 print(sum) 2 sum=42 3 print(sum) 4 5 def inc(n): 6 sum=n+1 7 print(sum) 8 return sum 9 10 sum=inc(7)+inc(7) 11 print(sum) 不是 1:内置 2:赋值 3:局部 4:全局 1 d 阅读全文
posted @ 2022-05-10 14:56 pray4hell 阅读(8) 评论(3) 推荐(0) 编辑
摘要: 1import random print('用列表存储随机整数:') ls = [random.randint(1,100) for i in range(5)] print(ls) print('\n用集合存储随机整数:') s1 = {random.randint(1,100) for i in 阅读全文
posted @ 2022-04-25 17:52 pray4hell 阅读(12) 评论(3) 推荐(0) 编辑
摘要: 1 # 基础操作练习: 列表及列表推导式、格式化、类型转换 2 x = list(range(10)) 3 print('整数输出1: ', end = '') 4 for i in x: 5 print(i, end=' ') 6 7 print('\n整数输出2: ', end = '') 8 阅读全文
posted @ 2022-04-11 17:02 pray4hell 阅读(7) 评论(3) 推荐(0) 编辑
摘要: 1 print('hey,u') 2 print('hey','u') 3 x,y,z=1,2,3 4 print(x,y,z) 5 print('x=%d,y=%d,z=%d'%(x,y,z)) 6 print('x={},y={},z={}'.format(x,y,z)) 7 print(f'x 阅读全文
posted @ 2022-03-26 22:45 pray4hell 阅读(15) 评论(3) 推荐(0) 编辑