摘要: 1 from turtle import* 2 3 def square(size=50,rgb='orange'): 4 pencolor(rgb) 5 for i in range(4): 6 fd(size) 7 left(90) 8 9 10 def main(): 11 setup(800 阅读全文
posted @ 2022-06-13 16:18 starry。 阅读(19) 评论(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-06 22:37 starry。 阅读(21) 评论(2) 推荐(0) 编辑
摘要: 1 with open('data3_id.txt', 'r', encoding = 'utf-8') as f: 2 datas=f.readlines() 3 datas=[line.strip().split(',') for line in datas] 4 data=[] 5 def i 阅读全文
posted @ 2022-05-23 22:12 starry。 阅读(19) 评论(2) 推荐(0) 编辑
摘要: 1 with open('data3.txt', 'r', encoding='utf-8') as f: 2 data = f.read().strip().split('\n') 3 data[0] = '原始数据' + '\t' + '四舍五入后数据' + '\n' 4 for i in ra 阅读全文
posted @ 2022-05-16 12:26 starry。 阅读(22) 评论(2) 推荐(0) 编辑
摘要: print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) 不是;line1、3、11是全局作用域。line7是函数作用域。 1 list1 = 阅读全文
posted @ 2022-05-09 22:10 starry。 阅读(28) 评论(1) 推荐(0) 编辑
摘要: 1 import random 2 print('用列表存储随机整数: ') 3 ls = [random.randint(1, 100) for i in range(5)] 4 print(ls) 5 print('\n用集合存储随机整数: ') 6 s1 = {random.randint(1 阅读全文
posted @ 2022-04-25 17:13 starry。 阅读(27) 评论(2) 推荐(0) 编辑
摘要: 1 # 基础操作练习: 列表及列表推导式、格式化、类型转换 2 x = list(range(10)) 3 print('整数输出1: ', end = '') 4 for i in x: 5 print(i, end=' ') 6 7 print('\n整数输出2: ', end = '') 8 阅读全文
posted @ 2022-04-11 13:23 starry。 阅读(27) 评论(2) 推荐(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 # 用 阅读全文
posted @ 2022-03-27 18:01 starry。 阅读(16) 评论(2) 推荐(0) 编辑