摘要: from turtle import * def square(size=50, rgb='orange'): '''绘制正方形 参数size指定边长 参数rgb指定画笔颜色 如果没有给参数,采用默认值''' pencolor(rgb) for i in range(4): fd(size) lef 阅读全文
posted @ 2022-06-15 00:23 阳光快楽男孩 阅读(8) 评论(1) 推荐(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 16:13 阳光快楽男孩 阅读(22) 评论(2) 推荐(0) 编辑
摘要: 1 title = ['城市', '人口(万)'] info = [ ['南京', '850'], ['纽约', '2300'], ['东京', '3800'], ['巴黎', '1000'] ] with open('city1.csv', 'w', encoding='utf-8') as f: 阅读全文
posted @ 2022-05-24 21:51 阳光快楽男孩 阅读(31) 评论(1) 推荐(0) 编辑
摘要: 1 with open('data1_1.txt','r',encoding='utf-8') as f: data=f.readlines() n=0 for line in data: if line.strip('\n')=='': continue n+=1 print('共{n}行') w 阅读全文
posted @ 2022-05-17 11:46 阳光快楽男孩 阅读(11) 评论(1) 推荐(0) 编辑
摘要: 1,第一个:sum函数未创建,在内建函数作用域中只能读不能改变 第二个:sum被赋予全局变量42 第三个:sum被赋予局部变量n+1 第四个;改变sum的全局变量为inc(7)+inc(7) 2,在line33后加入显示 在line38后加显示 python内置函数sorted()中,参数rever 阅读全文
posted @ 2022-05-04 22:40 阳光快楽男孩 阅读(39) 评论(3) 推荐(0) 编辑
摘要: 1。 问题1:范围是1到100闭区间,可以去取到100. 问题2:第一个范围是0到4闭区间,不能取到五,第二个范围1到4闭区间,不能取到五 问题3:不一定,random函数可能取重复值 问题四:一定 2 datas = {'2049777001': ['篮球', '羽毛球', '美食', '漫画'] 阅读全文
posted @ 2022-04-20 18:05 阳光快楽男孩 阅读(31) 评论(2) 推荐(0) 编辑
摘要: 1 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 = '-') p 阅读全文
posted @ 2022-04-06 22:44 阳光快楽男孩 阅读(33) 评论(1) 推荐(0) 编辑
摘要: 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 = {}'.format(x,y,z)) print(f'x = {x} 阅读全文
posted @ 2022-03-23 17:37 阳光快楽男孩 阅读(26) 评论(4) 推荐(0) 编辑