摘要: import timedef timmer(func): #func=test1 def wrapper(*args,**kwargs): #test('linhaifeng',age=18) args=('linhaifeng') kwargs={'age':18} start_time=time 阅读全文
posted @ 2020-02-01 16:20 小马嘿 阅读(272) 评论(0) 推荐(0)
摘要: 在Python中尽管也有三元表达式,但格式不同,先看下在Python中简单示例 ? 1 2 3 4 >>> x = 4 >>> y = 99 if x > 3 else 999 >>> y 99 从上面的Python是示例可以看出,Python的三元表达式格式如下: 条件为真时的结果 if 判段的条 阅读全文
posted @ 2020-01-15 15:38 小马嘿 阅读(538) 评论(0) 推荐(0)
摘要: dic = {'k1': 10, 'k2': 100, 'k3': 50, 'k4': 90}print(list(filter(lambda x: x[1] > 50, dic.items()))) # 把值大于50的由元祖组成的键值对过滤出来。 movie_people=['alex_sb',' 阅读全文
posted @ 2020-01-13 10:59 小马嘿 阅读(848) 评论(0) 推荐(0)
摘要: list.pop(obj=list[-1]) 默认为 index=-1 删除最后一个列表值 阅读全文
posted @ 2019-12-20 11:33 小马嘿 阅读(1482) 评论(0) 推荐(0)
摘要: name = "刚娘"def weihou(): name = "陈卓" def weiweihou(): nonlocal name # nonlocal,指定上一级变量,如果没有就继续往上直到找到为止 name = "冷静" weiweihou() print(name)print(name)w 阅读全文
posted @ 2019-12-18 19:12 小马嘿 阅读(197) 评论(0) 推荐(0)
摘要: # name='lhf'### def change_name():# global name# name='帅了一比'# print('change_name',name)# 阅读全文
posted @ 2019-12-17 21:03 小马嘿 阅读(208) 评论(0) 推荐(0)
摘要: y=2*x+1x=3y->7x=3y->7'''# def test(x):# '''# 2*x+1# :param x:整形数字# :return: 返回计算结果# '''# y=2*x+1# return y## def test():# '''# 2*x+1# :param x:整形数字# : 阅读全文
posted @ 2019-12-17 19:59 小马嘿 阅读(1273) 评论(0) 推荐(0)
摘要: # s=set('hello')# print(s)## s=set(['alex','alex','sb'])# print(s)# s={1,2,3,4,5,6}#添加# s.add('s')# s.add('3')# s.add(3)# print(s)# s.clear()# print(s 阅读全文
posted @ 2019-12-16 15:55 小马嘿 阅读(153) 评论(0) 推荐(0)
摘要: msg='i am %s my hobby is %s' % ('lhf','alex')# print(msg)## msg='i am %s my hobby is %s' % ('lhf',1)# msg='i am %s my hobby is %s' % ('lhf',[1,2])# pr 阅读全文
posted @ 2019-12-16 15:53 小马嘿 阅读(212) 评论(0) 推荐(0)
摘要: a="I am %s" %"你大爷" #百分号字符串连接print(a)#结果 I am 你大爷 %s 可以接收 所有类型的 %d 只能接收数字 阅读全文
posted @ 2019-12-16 15:43 小马嘿 阅读(313) 评论(0) 推荐(0)