摘要: 1 from turtle import * 2 def square(size=50,rgb='orange'): 3 pencolor(rgb) 4 for i in range(4): 5 fd(size) 6 left(90) 7 def main(): 8 setup(800,600) 9 阅读全文
posted @ 2022-06-14 10:16 张博睿 阅读(5) 评论(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-07 16:07 张博睿 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 1 def is_valid(x): 2 ls=[str(i) for i in range(0,10)] 3 ls.append('X') 4 if len(x)<18: 5 return False 6 for a in range(len(x)): 7 if x[a] not in ls: 8 阅读全文
posted @ 2022-05-24 10:19 张博睿 阅读(14) 评论(1) 推荐(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 range(1,len(dat 阅读全文
posted @ 2022-05-15 21:54 张博睿 阅读(21) 评论(1) 推荐(0) 编辑
摘要: 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.Built-in 2.Global 3.Lo 阅读全文
posted @ 2022-05-10 21:21 张博睿 阅读(14) 评论(1) 推荐(0) 编辑
摘要: 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 = {random.randi 阅读全文
posted @ 2022-04-25 21:00 张博睿 阅读(25) 评论(2) 推荐(0) 编辑
摘要: 1 x=list(range(10)) 2 print('整数输出1:',end='') 3 for i in x: 4 print(i,end=' ') 5 6 print('\n整数输出2:',end=' ') 7 for i in x: 8 print(f'{i:02d}',end='-') 阅读全文
posted @ 2022-04-10 20:07 张博睿 阅读(40) 评论(1) 推荐(0) 编辑
摘要: 1 print('hey, u') 2 3 4 print('hey','u') 5 x,y,z=1,2,3 6 print(x, y, z) 7 8 9 print('x=%d, y=%d, z=%d'%(x,y,z)) 10 print('x = {}, y = {}, z = {}'.form 阅读全文
posted @ 2022-03-27 21:25 张博睿 阅读(60) 评论(1) 推荐(0) 编辑
摘要: 1 P=1.038 2 c=3.7 3 K=5.4*10**(-3) 4 M=67 5 Tw=100 6 Ty=70 7 T0 = eval(input ('请输入一个数字T0:')) 8 from math import log 9 from math import pi 10 t=(((M**( 阅读全文
posted @ 2022-03-27 21:04 张博睿 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 1 x = eval(input ('请输入一个数字:')) 2 y = x**365 3 print(y) 阅读全文
posted @ 2022-03-27 20:27 张博睿 阅读(5) 评论(0) 推荐(0) 编辑