05 2018 档案
摘要:# -*- coding: cp936 -*- import requests from lxml import etree url = 'https://weibo.cn/pub/' html = requests.get(url).content #先用.content再用etree.HTML(html)方法,不然报错 selector = etree.HTML(html) ''' #...
阅读全文
摘要:content是bytes数据,包括图片等二进制数据;text是网页代码 content在python 2.7版本中可以顺利打印出网页代码;但是在Python3.6上面打印的中文是乱码,而且很卡,代码持续行状态 text在python 2.7版本中打印出网页代码中文乱码;在Python3.6上面打印
阅读全文
摘要:import re st = 'asxxixxsaefxxlovexxsdwdxxyouxxde' #search()和 findall()的区别 a = re.search('xx(.*?)xxsaefxx(.*?)xxsdwdxx(.*?)xx',st) #print(a) #运行结果 # #group()方法 b = re.search('xx(.*?)xxsaefxx(.*?)x...
阅读全文
摘要:贪心算法,非贪心算法
阅读全文