摘要: from turtle import * def square(size=50, rgb='orange'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值''' pencolor(rgb) for i in range(4): fd(size) lef 阅读全文
posted @ 2022-06-21 09:53 一个幽灵 阅读(4) 评论(0) 推荐(0) 编辑
摘要: class User: count=0 def __init__(self,name='guest',password=111111,state=1): self.name = name self.password = password self.state= state User.count+=1 阅读全文
posted @ 2022-06-08 09:46 一个幽灵 阅读(2) 评论(0) 推荐(0) 编辑
摘要: with open('data3_id.txt', 'r', encoding='utf-8') as f: data=f.readlines() data=[line.strip().split(',') for line in data] ans=[] def isvalid(id): if l 阅读全文
posted @ 2022-05-24 22:14 一个幽灵 阅读(3) 评论(1) 推荐(0) 编辑
摘要: with open('data3.txt','r+', encoding='UTF-8') as f: num = [line.strip('\n') for line in f] num.pop(0) num_print = [eval(i) for i in num] print(f"原始数据: 阅读全文
posted @ 2022-05-17 10:21 一个幽灵 阅读(5) 评论(1) 推荐(0) 编辑
摘要: task.1 print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) task.2 def func(a, b, c, /, *, d, e 阅读全文
posted @ 2022-05-11 09:04 一个幽灵 阅读(4) 评论(1) 推荐(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 21:02 一个幽灵 阅读(7) 评论(3) 推荐(0) 编辑
摘要: task.1x = list(range(10)) print('整数输出1: ', end = '') for i in x: print(i, end=' ') print('\n整数输出2: ', end = '') for i in x: print(f'{i:02d}', end = '- 阅读全文
posted @ 2022-04-13 09:13 一个幽灵 阅读(8) 评论(4) 推荐(0) 编辑
摘要: # task1_1.py print('hey, u') print('hey', ' u') x,y,z = 1,2,3 print(x, y, z) print('x = %d, y = %d, z = %d' %(x,y,z)) print('x = {}, y = {}, z = {}'.f 阅读全文
posted @ 2022-03-30 09:08 一个幽灵 阅读(19) 评论(5) 推荐(0) 编辑