上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 46 下一页
摘要: 注: json.dumps : dict转成str json.dump是将python数据保存成json json.loads:str转成dict json.load是读取json数据 阅读全文
posted @ 2018-02-02 16:22 耐烦不急 阅读(141) 评论(0) 推荐(0) 编辑
摘要: #序列化:序列化 (Serialization)将对象的状态信息转换为可以存储或传输的形式的过程。 #本例把字典数据类型存成字符串存在硬盘 #文件只能存字符串和二进制码,字典之类的不可以 info={ 'name':'Han Jianghua', 'age':22 } f=open('第71.text','w') f.write(str(info))#f.write(info)存... 阅读全文
posted @ 2018-02-02 16:21 耐烦不急 阅读(198) 评论(0) 推荐(0) 编辑
摘要: #hex() 转16进制 oct()转8进制 print(hex(255)) print(oct(10)) #id() 返回内存地址 print(id('a')) ''' isinstance(object, classinfo) 如果参数object是classinfo的实例,或者object是classinfo类的子类的一个实例, 返回True。 如果object不是一个给定类型的的对象, ... 阅读全文
posted @ 2018-02-02 11:47 耐烦不急 阅读(207) 评论(0) 推荐(0) 编辑
摘要: #abs()取绝对值 ''' all(iterable) Return True if all elements of the iterable are true (or if the iterable is empty). ''' print(all([0,9,-8,'a'])) print(all([9,-8,'a'])) ''' any(iterable) Return True if a... 阅读全文
posted @ 2018-02-02 00:24 耐烦不急 阅读(177) 评论(0) 推荐(0) 编辑
摘要: ''' 我们已经知道,可以直接作用于for循环的数据类型有以下几种: 一类是集合数据类型,如list、tuple、dict、set、str等; 一类是generator,包括生成器和带yield的generator function。 这些可以直接作用于for循环的对象统称为可迭代对象:Iterable。 可以使用isinstance()判断一个对象是否是Iterable对象: ''' from... 阅读全文
posted @ 2018-01-31 00:17 耐烦不急 阅读(235) 评论(0) 推荐(0) 编辑
摘要: Python自动化开发(金角大王版) http://www.cnblogs.com/alex3714/articles/5885096.html http://www.cnblogs.com/alex3714/articles/5885096.html http://www.cnblogs.com/ 阅读全文
posted @ 2018-01-30 16:25 耐烦不急 阅读(548) 评论(0) 推荐(0) 编辑
摘要: import time def consumer(name): print("%s 准备吃包子啦!"%name) while True: baozi = yield print("包子[%s]来了,被[%s]吃了!"%(baozi,name)) def producer(name): c = consumer('A') c2 = c... 阅读全文
posted @ 2018-01-30 16:24 耐烦不急 阅读(138) 评论(0) 推荐(0) 编辑
摘要: import time def consumer(name): print('%s准备吃包子 '%name) while True: baozi=yield print('包子[%s]来了,被[%s]吃了'%(baozi,name)) c=consumer('猪小芳') c.__next__()#调用yield b1='韭菜馅' #以下两条语句,有... 阅读全文
posted @ 2018-01-30 16:23 耐烦不急 阅读(144) 评论(0) 推荐(0) 编辑
摘要: # map()函数 # map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回。 # 例如,对于list [1, 2, 3, 4, 5, 6, 7, 8, 9] # 如果希望把list的每个元素都作平方,就可以用map()函数: # 因此,我们只需要传入函数f(x)=x*x,就可以利用... 阅读全文
posted @ 2018-01-30 16:22 耐烦不急 阅读(350) 评论(0) 推荐(0) 编辑
摘要: # home密码认证是本地文件认证,bbs密码认证是远程ldat认证 import time user, passwd = 'qi', '123' def auth(auth_type): print('auth func:', auth_type) def outwrapper(func): def wrappper(*args, **kwargs): ... 阅读全文
posted @ 2018-01-30 00:11 耐烦不急 阅读(169) 评论(0) 推荐(0) 编辑
上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 46 下一页