上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 80 下一页
摘要: # 格式化字符串 name='fqs' age=18 hobby='game' print(f'第一种name:{name:10},age:{age:10}') print('第二种name:{0:10},age:{1:10}'.format(name,age)) print('第三种name:{0 阅读全文
posted @ 2023-07-10 14:22 胖豆芽 阅读(27) 评论(0) 推荐(0)
摘要: # 99乘法表for i in range(1,10): for j in range(1,i+1): print(f'{j}*{i}={i*j}',end='\t')#制表符 使得更整齐 print(' ') 阅读全文
posted @ 2023-07-09 17:24 胖豆芽 阅读(12) 评论(0) 推荐(0)
摘要: print(1,2,3,end='')# 不换行,一行内 输出下一列的值 print(4) ''' 1 2 34 ''' 阅读全文
posted @ 2023-07-09 16:55 胖豆芽 阅读(23) 评论(0) 推荐(0)
摘要: phone1_3=int(phone1[:3]) if not phone1.isdigit(): print("非法输入") else: if len(phone1)!=11: print("非法输入") else: if phone1_3>=130 and phone1_3<=150: prin 阅读全文
posted @ 2023-07-09 16:16 胖豆芽 阅读(24) 评论(0) 推荐(0)
摘要: a=1 b=10 a,b=b,a print(a,b)#10 1 阅读全文
posted @ 2023-07-09 13:33 胖豆芽 阅读(14) 评论(0) 推荐(0)
摘要: l=sorted([36, 5, -12, 9, -21]) print(l) ''' [-21, -12, 5, 9, 36] ''' l=sorted([36, 5, -12, 9, -21],key=abs) print(l) ''' [5, 9, -12, -21, 36] ''' # 按照 阅读全文
posted @ 2023-07-08 21:45 胖豆芽 阅读(14) 评论(0) 推荐(0)
摘要: # 去掉空白的字符 def not_empty(s): return s and s.strip() l=list(filter(not_empty, ['A', '', 'B', None, 'C', ' '])) print(l) ''' ['A', 'B', 'C'] ''' 阅读全文
posted @ 2023-07-08 21:39 胖豆芽 阅读(13) 评论(0) 推荐(0)
摘要: # 求x的平方的列表 l = list(map(lambda x: x*x, [1, 2, 3, 4])) print(l)# [1, 4, 9, 16] names = ['adam', 'LISA', 'barT'] formatted_names = list(map(lambda x: x. 阅读全文
posted @ 2023-07-08 21:24 胖豆芽 阅读(68) 评论(0) 推荐(0)
摘要: # 自动生成 1 2 3 l=list(range(1,4)) print(l) #求 1*1 2*2 3*3 l2=[] for x in range(1,4): l2.append(x*x) print(l2) # 简化 print([x * x for x in range(1, 4)]) # 阅读全文
posted @ 2023-07-08 20:40 胖豆芽 阅读(18) 评论(0) 推荐(0)
摘要: # 字符串的for 循环 str1 = 'abc' for i in str1: print(i) ''' a b c ''' # 字典的for 循环 dict1 = {'name':'fqs','age':18,'address':'beijing'} for key in dict1: prin 阅读全文
posted @ 2023-07-08 19:54 胖豆芽 阅读(12) 评论(0) 推荐(0)
上一页 1 ··· 38 39 40 41 42 43 44 45 46 ··· 80 下一页