2019年3月6日 星期三

Python各種內藏方法

# 初始化方法
def __init__(self):
# 直接呼叫, representation
def __repr__(self):
# 使用print會呼叫
def __str__(self):
# 迭代方法
def __iter__(self):
ex. 
  1. for i in xrange(1000): pass  
  2. #返回迭代對象