随笔分类 - python 入门学习
摘要:import time scale = 50 print("执行开始".center(scale//2,"-")) start = time.perf_counter() for i in range(scale+1): a="*"*i b="."*(scale-i) c=(i/scale)*100 dur = time.perf_counter() pr...
阅读全文
摘要:temp = input("请输入密码:") password = "我好喜欢你" times=3 while times>0: if "*" in temp: temp=input("密码中不能含有“*”号!您还有3次机会!请重新输入:") elif temp == password: break temp=input("密码错误,...
阅读全文
摘要:temp = input("请输入一个年份:") while not temp.isdigit(): print("您的输入不合法") temp = input("请输入一个年份:") year = int(temp) if (year %4==0 and year %100 !=0) or year%400 ==0: print("您输入的年份是闰年") else: ...
阅读全文
摘要:0.向列表增加元素有哪些方法 法一:使用append 方法若列表为s 则s.append() 添加到列表末尾,只能添加一个元素 法二:使用extend方法 若列表为s 则s.extend() 用一个列表扩展另一个列表,用于在末尾添加多个元素 法三:使用insert方法 若列表为s 则s.insert
阅读全文
摘要:assert 0.猜猜 (x < y and [x] or [y])[0] 实现什么样的功能? 若x<y为真,则返回x (参照两边为数的逻辑运算:A and B,若A为真,则返回B,反之,返回A A or B ,若A为真,则返回B,反之,返回A )(其中[X][0]表示列表中的第一个元素即X) 若x
阅读全文