摘要: 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 13:03 曲珞阳 阅读(20) 评论(1) 推荐(0) 编辑
摘要: def main(): passif __name__ == '__main__': main()def main(): passif __name__ == '__main__': main()class User: """用户""" count = 0 def __init__(self, na 阅读全文
posted @ 2022-06-06 22:38 曲珞阳 阅读(104) 评论(2) 推荐(0) 编辑
摘要: with open('C://data3_id.txt', 'r', encoding = 'utf-8') as f: datas=f.readlines() datas=[line.strip().split(',') for line in datas] data=[]def isvalid( 阅读全文
posted @ 2022-05-22 12:27 曲珞阳 阅读(9) 评论(1) 推荐(0) 编辑
摘要: with open('D://a//data3.txt', 'r', encoding = 'utf-8') as f: data = f.read().split('\n') x=[] for line in data: if data.count(line)==1: x.append(line) 阅读全文
posted @ 2022-05-15 14:59 曲珞阳 阅读(21) 评论(1) 推荐(0) 编辑
摘要: print(sum)sum=42print(sum) def inc(n): sum=n+1 print(sum) return sum sum=inc(7)+inc(7) print(sum) 实验结果: 不代表同一变量名. 一:内置作用域 二:全局作用域 三:局部作用域 四:全局作用域 def 阅读全文
posted @ 2022-05-09 21:59 曲珞阳 阅读(25) 评论(1) 推荐(0) 编辑
摘要: 实验任务1 import random print('用列表存储随机整数: ') ls = [random.randint(1, 100) for i in range(5)] print(ls) print('\n用集合存储随机整数: ') s1 = {random.randint(1,100) 阅读全文
posted @ 2022-04-21 18:19 曲珞阳 阅读(11) 评论(0) 推荐(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 = ' 阅读全文
posted @ 2022-04-10 16:59 曲珞阳 阅读(24) 评论(2) 推荐(0) 编辑
摘要: print('hey, u') 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)) 阅读全文
posted @ 2022-03-26 19:00 曲珞阳 阅读(84) 评论(1) 推荐(0) 编辑