摘要: 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-09 19:19 桑羽 阅读(28) 评论(0) 推荐(0) 编辑
摘要: class User: def __init__(self, name, password='111111', status='1'): # 构造新账户 self.name = name self.password = password self.status = status def info(s 阅读全文
posted @ 2022-06-07 12:59 桑羽 阅读(10) 评论(1) 推荐(0) 编辑
摘要: def is_valid(x): ls = [str(i) for i in range(0, 10)] ls.append('X') if len(x) < 18: return False for a in range(len(x)): if x[a] not in ls: return Fal 阅读全文
posted @ 2022-05-24 16:40 桑羽 阅读(8) 评论(2) 推荐(0) 编辑
摘要: task3 with open('data3.txt','r',encoding='utf-8') as f : with open('data3_processed.txt', 'w', encoding='utf-8') as f1: data=f.read().strip().split('\ 阅读全文
posted @ 2022-05-16 21:17 桑羽 阅读(9) 评论(1) 推荐(0) 编辑
摘要: task1 print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 1.内置函数名 2.赋值名 3.局部变量 4.全局变量 task2 de 阅读全文
posted @ 2022-05-10 13:01 桑羽 阅读(9) 评论(2) 推荐(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 阅读全文
posted @ 2022-04-26 23:30 桑羽 阅读(28) 评论(5) 推荐(0) 编辑
摘要: task1.py x=list(range(10)) print('整数输出1:',end='') for i in x: print(f'{i:02d}', end = '-') print('\n整数输出2:',end='') for i in x: print(f'{1:02d}',end=' 阅读全文
posted @ 2022-04-12 15:00 桑羽 阅读(22) 评论(2) 推荐(0) 编辑
摘要: task1_1.py print的几种用法: 1.用于输出单个字符或单个变量 2.用于输出多个数据项,逗号隔开 3.用于混合字符和变量值 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 阅读全文
posted @ 2022-03-27 21:56 桑羽 阅读(27) 评论(3) 推荐(0) 编辑