# 序列化逻辑
if not os.path.exists('session.txt'):
with open('session.txt','wb') as f:
import pickle
cookies = response.request.headers['cookie']
cookieDict={}
for cookie in cookies.split(';'):
key,value = cookie[0:cookie.find('=')], cookie[cookie.find('=')+1:]
cookieDict[key]=value
pickle.dump(cookieDict,f)
# 方法
def parse_user_info(self,response):
......
cookie序列化的代码并没有放在'方法内部',而是跟方法同级的.它是如何被触发执行的?