摘要: from turtle import* def square(size=50,rgb='orange'): pencolor(rgb) for i in range(4): fd(size) left(90) def main(): setup(800,600) speed(10) n=10 for 阅读全文
posted @ 2022-06-13 19:30 琦哲 阅读(25) 评论(2) 推荐(0) 编辑
摘要: class User: def __init__(self, name='guest', password=111111, status=1): self._name = name self._password = password self._status = status def info(se 阅读全文
posted @ 2022-06-07 00:20 琦哲 阅读(38) 评论(3) 推荐(0) 编辑
摘要: def is_valid(a): if len(a)==18 : if a.isdigit() or( a[:-1].isdigit() and a[-1]=='X'): return True else: return False else: return False with open('D:/ 阅读全文
posted @ 2022-05-23 21:16 琦哲 阅读(13) 评论(3) 推荐(0) 编辑
摘要: with open('D://aa//data3.txt','r',encoding='utf-8')as f: data=f.read().split('\n') list1=data[1:11] print("原始数据:") print(list1) list2=[] for i in list 阅读全文
posted @ 2022-05-13 18:31 琦哲 阅读(41) 评论(3) 推荐(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是函数作用域。 Task2 li 阅读全文
posted @ 2022-05-06 18:36 琦哲 阅读(38) 评论(2) 推荐(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-20 23:14 琦哲 阅读(39) 评论(3) 推荐(0) 编辑
摘要: 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 = '-') pri 阅读全文
posted @ 2022-04-10 22:14 琦哲 阅读(34) 评论(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-27 18:31 琦哲 阅读(18) 评论(3) 推荐(0) 编辑