def _process_user_item(self, item): item['name'] = item['name'] item['join_date'] = datetime.strptime(item['join_date'], '%Y-%m-%d').date() item['learn_courses_num'] = int(item['learn_courses_num']) self.session.add(User(**item))
def _process_user_item(self, item): item['level'] = int(item['level'][1:]) item['join_date'] = datetime.strptime( item['join_date'].split()[0], '%Y-%m-%d').date() item['learn_courses_num'] = int(item['learn_courses_num']) if item['school_job']: self.session.add(User(**item))
def _process_user_item(self, item): # 抓到的数据类似 'L123456' 需要去掉L并转化为int item['level'] = int(item['level'][1:]) # 抓取到的数据类似 '2019-01-01 加入实验楼', 把其中的日期字符转换成date对象 item['join_date'] = datetime.strptime(item['join_date'].split()[0], '%Y-%m-%d') item['learn_courses_num'] = int(item['learn_courses_num']) self.session.add(User(**item))
def _process_user_item(self, item): # 抓取到的数据类似 'L100',需要去掉 'L' 然后转化为 int item['level'] = int(item['level'][1:]) # 抓去到的数据类似 '2017-01-01 加入实验楼' 其中的把日期字符串转换为 date 对象 item['join_date'] = datetime.strptime(item['join_date'].split()[0], '%Y-%m-%d').date() # 学习课程数目转化为 int item['learn_courses_num'] = int(item['learn_courses_num']) # 添加到 session self.session.add(User(**item))
def _process_user_item(self, item): item['level'] = int(item['level'][1:]) #change L26 into 26 item['join_date'] = datetime.strptime(item['join_date'].split()[0], '%Y-%m-%d').date() #convert '2017-01-01 joined shiyanlou' into a date object item['learn_course_num'] = int(item['learn_course_num']) self.session.add(User(**item)) return item
def _process_user_item(self, item): # ???????? 'L100'????? 'L' ????? int item['level'] = int(item['level'][1:]) # ???????? '2017-01-01 ?????' # ???????????? date ?? item['join_date'] = datetime.strptime(item['join_date'].split()[0], '%Y-%m-%d').date() # ????????? int item['learn_courses_num'] = int(item['learn_courses_num']) # ??? session self.session.add(User(**item))
def _process_user_item(self, item): item['level'] = int(item['level'][1:]) item['join_date'] = datetime.strptime( item['join_date']).split()[0], '%y-%m-%d' item['learn_courses_num'] = int(item(['learn_courses_num'])) self.session.add(User(**item))
def _process_user_item(self,item): item['level'] = int(item['level'][1:]) item['join_date'] = datetime.strptime(item['join_date'].split()[0], '%Y-%m-%d') item['learn_courses_num'] = int(item['learn_courses_num']) self.session.add(User(**item)) print('---------------------------------', item.get('name'))
def _process_user_item(self, item): item['level'] = int(item['level'][1:]) # 去掉等级前面的L item['join_date'] = datetime.strptime(item['join_date'], '%Y-%m-%d') item['learn_courses_num'] = int(item['learn_courses_num']) self.session.add(User(**item))