字典和json字符串(本质也是字符串)之间的转化用json.dumps和json.loads() json.dumps(): 字典→json字符串 json.loads(): json字符串→字典 字符串和字节串之间的转化用encode()和decode() encode(): 字符串→字节串 de ...
分类:
编程语言 时间:
2019-12-17 18:16:10
阅读次数:
199
xpath解析是我们在爬虫中最常用也是最通用的一种数据解析方式。 环境安装 pip install lxml 解析原理 使用通用爬虫爬取网页数据 实例化etree对象,且将页面数据加载到该对象中 使用xpath函数结合xpath表达式进行标签定位和指定数据提取 实例化etree对象 - 1.将本地的 ...
分类:
其他好文 时间:
2019-12-17 14:44:18
阅读次数:
108
博客园添加目录,导航,回到顶部 1. 在博客园设置中申请js权限,写明申请理由大约2 3小时通过 2. 通过后在后台设置中添加CSS代码,填写在 区域 3. 在后台设置中添加javascript代码,填写在 区域 ...
分类:
其他好文 时间:
2019-12-16 19:24:33
阅读次数:
80
A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty strin ...
分类:
其他好文 时间:
2019-12-16 10:17:31
阅读次数:
122
# 引入扩展 from urllib import request, error, parse # 定义url、请求头、请求参数 url = "http://www.baidu.com" headers = {'User-Agent': 'Mozilla/5.0 3578.98 Safari/537 ...
分类:
Web程序 时间:
2019-12-15 12:43:09
阅读次数:
88
题目如下: You have a pointer at index 0 in an array of size arrLen. At each step, you can move 1 position to the left, 1 position to the right in the arra ...
分类:
其他好文 时间:
2019-12-15 10:23:42
阅读次数:
83
# 作者:王佃元# 日期:2019/12/14name = '你好,世界'name1 = name.encode('utf-8')print(name1)name2 = name1.decode('utf-8')print(name2)name3 = name2.encode('gbk')print ...
分类:
其他好文 时间:
2019-12-15 00:59:46
阅读次数:
90
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl ...
分类:
其他好文 时间:
2019-12-13 14:08:00
阅读次数:
76
python爬虫 urllib用法 eg1: from urllib import request data = request.urlopen(urlString).read() data获取的是该网页的所有源码内容 data=data.decode("utf 8") 对data编码 import ...
分类:
编程语言 时间:
2019-12-13 13:36:13
阅读次数:
81
字符串前加u 后面字符串以 Unicode格式进行编码,一般用在中文字符串前面,防止因为源码储存格式问题,导致再次使用时出现乱码。 字符串前加r 去掉反斜杠的转移机制。(特殊字符:即那些,反斜杠加上对应字母,表示对应的特殊含义的,比如最常见的”\n”表示换行,”\t”表示Tab等。 ) 应用: 常用 ...
分类:
编程语言 时间:
2019-12-11 13:34:26
阅读次数:
108