摘要: def main(): passif __name__ == '__main__': main()from turtle import*def square(size=50,rgb='pink'): pencolor(rgb) for i in range(4): fd(size) left(90) 阅读全文
posted @ 2022-06-14 00:24 黄海祥 阅读(24) 评论(1) 推荐(0) 编辑
摘要: class User: def __init__(self,name='guest',password=111111,status=1): self.name=name self.password=password self.status=status def info(self): print(' 阅读全文
posted @ 2022-06-07 22:40 黄海祥 阅读(23) 评论(2) 推荐(0) 编辑
摘要: def main(): passif __name__ == '__main__': main()def is_valid(x): if len(x)==18 and (x.isdigit() or x[-1]=='X'): return Truem=[]with open('data3_id.tx 阅读全文
posted @ 2022-05-22 23:41 黄海祥 阅读(16) 评论(2) 推荐(0) 编辑
摘要: task3def main(): passif __name__ == '__main__': main()with open('data3.txt','r')as f: data=f.read().split('\n')del data[0]a=list(data)b,m=[],[]for i i 阅读全文
posted @ 2022-05-16 22:53 黄海祥 阅读(18) 评论(3) 推荐(0) 编辑
摘要: task1.py print(sum) sum = 42 print(sum) def inc(n): sum = n+1 print(sum) return sum sum = inc(7) + inc(7) print(sum) line3余line11为同一变量,line1为未确定变量,作用域 阅读全文
posted @ 2022-05-10 21:39 黄海祥 阅读(29) 评论(2) 推荐(0) 编辑
摘要: 1 import random 2 print('用列表存储随机整数: ') 3 ls = [random.randint(1, 100) for i in range(5)] 4 print(ls) 5 print('\n用集合存储随机整数: ') 6 7 s1 = {random.randint 阅读全文
posted @ 2022-04-26 19:09 黄海祥 阅读(25) 评论(1) 推荐(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-11 22:26 黄海祥 阅读(36) 评论(3) 推荐(0) 编辑
摘要: 1 print('hey u') 2 3 print('hey','u') 4 x,y,z=1,2,3 5 print(x,y,z) 6 7 print('x=%d,y=%d,z=%d'%(x, y, z)) 8 print('x={},y={},z={}'.format(x,y,z)) 9 pri 阅读全文
posted @ 2022-03-28 16:55 黄海祥 阅读(19) 评论(5) 推荐(0) 编辑