摘要: from turtle import * def square(size=50, rgb='pink'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值 ''' pencolor(rgb) for i in range(4): fd(size) left 阅读全文
posted @ 2022-06-12 17:09 我真是想笑 阅读(10) 评论(0) 推荐(0) 编辑
摘要: class User: num=0 def __init__(self,name='guest',password='111111',status='1'): User.num+=1 self.name=name self.password=password if status=='1': self 阅读全文
posted @ 2022-06-07 16:06 我真是想笑 阅读(4) 评论(0) 推荐(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 False br 阅读全文
posted @ 2022-05-24 21:48 我真是想笑 阅读(5) 评论(0) 推荐(0) 编辑
摘要: with open('data5.txt','r',encoding='utf-8')as f: data = f.read() line_num = len(data.splitlines()) word_num = len(data.split()) space_num = data.count 阅读全文
posted @ 2022-05-15 15:54 我真是想笑 阅读(8) 评论(1) 推荐(0) 编辑
摘要: 1 print(sum) 2 sum = 42 3 print(sum) 4 def inc(n): 5 sum = n+1 6 print(sum) 7 return sum 8 sum = inc(7) + inc(7) 9 print(sum) def func1(a, b, c, d, e, 阅读全文
posted @ 2022-05-10 17:24 我真是想笑 阅读(9) 评论(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 阅读全文
posted @ 2022-04-26 17:40 我真是想笑 阅读(17) 评论(4) 推荐(0) 编辑
摘要: x = list(range(10)) print('整数输出1: ', end = '') for i in x: print(f'{i:02d}', end = '-') print('\n整数输出3: ', end = '') for i in x[:-1]: print(f'{i:02d}' 阅读全文
posted @ 2022-04-12 19:26 我真是想笑 阅读(5) 评论(3) 推荐(0) 编辑
摘要: x1, y1 = 1.2, 3.57 x2, y2 = 2.26, 8.7 # 输出1 print('{:-^40}'.format('输出1')) print('x1 = {}, y1 = {}'.format(x1, y1)) print('x2 = {}, y2 = {}'.format(x2 阅读全文
posted @ 2022-03-23 16:53 我真是想笑 阅读(18) 评论(3) 推荐(0) 编辑