使用Itchat模块和图灵机器人API实现个人微信的自动回复( 三 )


自定义微语,随机提取一条微语
num = random.randint(0,len(self.variety_config_info['get_weiyu']))print(len(self.variety_config_info['get_weiyu']))ana = '\n【微语】' + self.variety_config_info['get_weiyu'][num]
'''每日科技早报'''def grab_readhub_data(self):self.get_readhub_title() # 得到readhub网页的每日早报所有标题信息head_info = self.parse_cale() # 得到日历格式# 遍历每日早报最新标题for index,title in enumerate(self.variety_config_info['get_readhub_title'],1):new = '{0}、{1};\n'.format(index,title) # 每一条标题格式# 将每一条标题格式添加到new_readhub_titleself.variety_config_info['new_readhub_title'].append(new) # 将self.variety_config_info['new_readhub_title']拼接成一个新字符串technology_new = ''.join(self.variety_config_info['new_readhub_title'])num = random.randint(0,len(self.variety_config_info['get_weiyu']))print(len(self.variety_config_info['get_weiyu']))ana = '\n【微语】' + self.variety_config_info['get_weiyu'][num]new_data_pack = str(head_info) + technology_new + ana # 标题信息+科技日报 return new_data_pack # 返回科技日报信息