摘要: enumerate(iterable, start=0) __next__()方法 更多: Loop Methods 循环技巧 阅读全文
posted @ 2019-01-31 16:33 怒放吧! 阅读(247) 评论(0) 推荐(0)
摘要: # 装饰器函数,表示一个类方法 class C: @classmethod def f(cls, args): # cls参数:类对象参数 print(cls) print(args) C.f('类对象调用类方法') c = C() # 创建实例 c.f('类实例对象调用类方法') 阅读全文
posted @ 2019-01-31 14:38 怒放吧! 阅读(154) 评论(0) 推荐(0)
摘要: 更多: ord() 阅读全文
posted @ 2019-01-31 10:34 怒放吧! 阅读(425) 评论(0) 推荐(0)
摘要: # 判断对象是否可调用,可调用,即对象后加() s = "abc" ls = [1,2,3] def f(): pass class F(): pass t =(s, ls, f, F) for obj in t: if callable(obj): print(obj, True) else: print(obj, Fal... 阅读全文
posted @ 2019-01-31 10:21 怒放吧! 阅读(166) 评论(0) 推荐(0)
摘要: # source是字符串,则使用str.encode()转换 b = bytes('abc',encoding='utf-8',errors='strict') print(b,b[0]) # bytes对象不可变 try: b[0] = 100 except TypeError as err: print('it is immutable.so',err) 阅读全文
posted @ 2019-01-31 10:11 怒放吧! 阅读(163) 评论(0) 推荐(0)
摘要: bytearray: 类,可变字节数组 阅读全文
posted @ 2019-01-31 09:31 怒放吧! 阅读(218) 评论(0) 推荐(0)
我的