摘要: from turtle import * def square(size=50,rgb='yellow'): pencolor(rgb) for i in range(4): fd(size) left(90) setup(800,600) speed(0) n=10 for i in range( 阅读全文
posted @ 2022-06-09 11:39 杜雨萱 阅读(29) 评论(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-05 10:57 杜雨萱 阅读(15) 评论(1) 推荐(0) 编辑
摘要: def is_valid(x): if len(x)!=18: return False for i in x: if not (i.isdigit() or i=='X'): return False else: return True with open('data3_id.txt','r',e 阅读全文
posted @ 2022-05-22 09:34 杜雨萱 阅读(29) 评论(2) 推荐(0) 编辑
摘要: 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('\n') da 阅读全文
posted @ 2022-05-15 11:35 杜雨萱 阅读(21) 评论(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) 问题:1.内置函数2.全局变量3.局部变量4.全局变量 实验二: def f 阅读全文
posted @ 2022-05-08 19:31 杜雨萱 阅读(22) 评论(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-21 21:37 杜雨萱 阅读(17) 评论(1) 推荐(0) 编辑
摘要: for i in x: print(f'{i:02d}', end = '-') print('\n整数输出3: ', end = '') for i in x[:-1]: print(f'{i:02d}', end = '-') print(f'{x[-1]:02d}') print('\n字符输 阅读全文
posted @ 2022-04-10 11:47 杜雨萱 阅读(22) 评论(1) 推荐(0) 编辑
摘要: 试验任务一: 1 #print输出的几种用法 2 3 #用法1:用于输出单个字符串或单个变量 4 print('hey','u') 5 6 #用法2: 用于输出多个数据项,用逗号分隔 7 print('hey','u') 8 x,y,z=1,2,3 9 print(x,y,z) 10 11 #用法3 阅读全文
posted @ 2022-03-25 18:54 杜雨萱 阅读(60) 评论(2) 推荐(0) 编辑