class B: def __init__(self,name,age): self.name = name self.age = age #创建迭代方法 def __iter__(self): return iter([11,22,33,44,55]) obj = B("alex",15) #运用的迭代器的方式获取数据 for i in obj: print(i)
基本数据类型补充: set 是一个无序且不重复的元素集合 class set(object): """ set() -> new empty set object set(iterable) -> new set object Build an unordered collection of unique elements. """ def add(self, *args, **kwargs): # real signature un
1.编译python遇到下面的编码问题: SyntaxError: Non-ASCII character '\xe9' in file E:\projects\learn.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details 解决方法:解决方法:源代码文件第一行添加:#coding:utf-8 2.python快速教程:http://www.cnb
/int整数/ 如: 18.73.84 每一个整数都具备如下功能: class int(object): """ int(x=0) -> int or long int(x, base=10) -> int or long Convert a number or string to an integer, or return 0 if no arguments are given. If x is floating point, the conversion tr
""" The main QuerySet implementation. This provides the public API for the ORM. """ import copy import sys import warnings from collections import OrderedDict, deque from django.conf import settings from django.core import ex
参考: 1. The Clean Architecture in Python (Brandon Rhodes) 2. Python Best Practice Patterns (Vladimir Keleshev) 3. Transforming Code into Beautiful, Idiomatic Python (Raymond Hettinger) 4. How to Write Resuable Code (Greg Ward) 5. How to write actually