摘要: 1 from turtle import * 2 def square(size=50, rgb='orange'): 3 '''绘制正方形 4 参数size指定边长 5 参数rgb指定画笔颜色 6 如果没有给参数,采用默认值 7 ''' 8 pencolor(rgb) 9 for i in ran 阅读全文
posted @ 2022-06-14 00:04 velpro1129 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 1 class User: 2 def __init__(self, name, password='111111', status='1'): # 构造新账户 3 self.name = name 4 self.password = password 5 self.status = status 阅读全文
posted @ 2022-06-08 15:54 velpro1129 阅读(4) 评论(0) 推荐(0) 编辑
摘要: task1_1.py 1 title = ['城市', '人口(万)'] 2 info = [ ['南京', '850'], 3 ['纽约', '2300'], 4 ['东京', '3800'], 5 ['巴黎', '1000'] ] 6 with open('city1.csv', 'w', en 阅读全文
posted @ 2022-05-25 13:03 velpro1129 阅读(14) 评论(0) 推荐(0) 编辑
摘要: task1_1.py 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 阅读全文
posted @ 2022-05-16 23:44 velpro1129 阅读(28) 评论(1) 推荐(0) 编辑
摘要: task1.py 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) 不是 1.内置函数2.全局变量 阅读全文
posted @ 2022-05-10 16:38 velpro1129 阅读(24) 评论(2) 推荐(0) 编辑
摘要: task1.py 1 import random 2 3 print('用列表存储随机整数: ') 4 ls = [random.randint(1,100)for i in range(5)] 5 print(ls) 6 7 print('\n用集合存储随机整数: ') 8 s1 = {rando 阅读全文
posted @ 2022-04-25 09:55 velpro1129 阅读(29) 评论(2) 推荐(0) 编辑
摘要: task1.py 1 x = list(range(10)) 2 3 print('整数输出1: ', end = '') 4 for i in x: 5 print(i, end=' ') 6 7 print('\n整数输出2: ', end = '') 8 for i in x: 9 print 阅读全文
posted @ 2022-04-11 21:21 velpro1129 阅读(18) 评论(3) 推荐(0) 编辑
摘要: task1_1.py #print的几种用法 #用法1 print('hey, u') #用法2 print('hey', ' u') x,y,z = 1,2,3 print(x, y, z) #用法3 print('x = %d, y = %d, z = %d'%(x,y,z)) print('x 阅读全文
posted @ 2022-03-28 11:32 velpro1129 阅读(43) 评论(2) 推荐(0) 编辑