摘要: from turtle import* def square(size=50,rgb='orange'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800,600) speed(0) n=10 for 阅读全文
posted @ 2022-06-13 21:28 Saloi 阅读(14) 评论(1) 推荐(0) 编辑
摘要: class User: def __init__(self,name='guest',password=111111,status=1): self.name=name self.password=password self.status=status def info(self): print(' 阅读全文
posted @ 2022-06-06 21:54 Saloi 阅读(25) 评论(1) 推荐(0) 编辑
摘要: def is_valid(id): if len(id[1]) == 18 and (id[1][:-1].isdigit() and id[1][-1] in '0123456789X'): return True return False with open('data3_id.txt', 'r 阅读全文
posted @ 2022-05-25 12:07 Saloi 阅读(6) 评论(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-16 22:24 Saloi 阅读(19) 评论(1) 推荐(0) 编辑
摘要: print(sum) sum=42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 不是,line1、3、11是全局作用域,line7是函数作用域。 TASK2 def f 阅读全文
posted @ 2022-05-10 19:20 Saloi 阅读(27) 评论(1) 推荐(0) 编辑
摘要: import random print('用列表存储随机整数:') ls=[random.randint(1,100) for i in range(5)] print(ls) print('\n用集合存储随机整数:') s1={random.randint(1,100) for i in rang 阅读全文
posted @ 2022-04-25 17:10 Saloi 阅读(18) 评论(3) 推荐(0) 编辑
摘要: TASK1 x = 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-11 19:20 Saloi 阅读(16) 评论(3) 推荐(0) 编辑
摘要: TASK1 Task1_1 # print输出的几种用法 # 用法1:用于输出单个字符串或单个变量 print('hey, u') # 用法2: 用于输出多个数据项,用逗号分隔 print('hey', ' u') x,y,z = 1,2,3 print(x, y, z) # 用法3: 用户混合字符 阅读全文
posted @ 2022-03-24 10:24 Saloi 阅读(14) 评论(2) 推荐(0) 编辑