摘要: 匿名函数定义 1.用匿名函数,找出最大value值对应的键 dict={"key1":20,"key2":80,"key":40} print(max(dict,key=lambda k:dict[k])) #函数的参数里面带key的有map filter min max sorted 一共就这5个 阅读全文
posted @ 2019-10-15 21:25 小王要变强 阅读(120) 评论(0) 推荐(0) 编辑
摘要: # import time# for i in range(1,101,2):# time.sleep(0.1)# char_num=i//2# per_str="\r%s%% :%s\n"%(i,'*'*char_num) \# if i==100 else "\r%s%% :%s" % (i,' 阅读全文
posted @ 2019-10-15 20:04 小王要变强 阅读(101) 评论(0) 推荐(0) 编辑
摘要: print(bytes("你好",encoding="GBK")).decode("GBK")#unicode转变为GBK print(bytes("你好",encoding="utf-8"))#unicode转换成utf-8 网络编程 只能存二进制 照片和视频也是以二进制存的 html网页爬取也是 阅读全文
posted @ 2019-10-15 20:02 小王要变强 阅读(534) 评论(0) 推荐(0) 编辑
摘要: # print(locals())#返回本地作用域的所有名字# print(globals())#返回全局作用域的所有名字# #global全局变量# #nonlocal局部变量# #dir()查看所拥有的方法# #colable()查看这个函数能否被调用,如果能被调用返回True# #print( 阅读全文
posted @ 2019-10-15 16:31 小王要变强 阅读(107) 评论(0) 推荐(0) 编辑
摘要: def Add(n,i): return n+i; def Number(): for i in range(1,10) yield i g=number() n=2 g1=(Add(n,i) for i in g) n=5 g2=(add(n,i )for i in g1) print(list( 阅读全文
posted @ 2019-10-15 10:14 小王要变强 阅读(96) 评论(0) 推荐(0) 编辑