![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
zoey要早起
这个作者很懒,什么都没留下…
展开
-
【Python】json
json.dumps 将 Python 对象编码成 JSON 字符串 json.loads 将已编码的 JSON 字符串解码为 Python 对象 import json import pytest #将string转换成dict #见到 : 和 , 就自动转换成dict def test_loads(): s = '{"k1": "v1"}' # 注意:由于是字符串,所以有'' loads_sth = json.loads(s) assert type(loads_sth)原创 2021-03-08 09:35:42 · 62 阅读 · 0 评论 -
【Python】爬取子域名
利用站长之家的子域名查询工具 import json import requests from lxml import etree url = "http://tool.chinaz.com/subdomain/zoom.us" #修改最后 headers = { "Host": "tool.chinaz.com", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) Ap原创 2021-02-04 13:30:02 · 640 阅读 · 1 评论 -
【Python】遇到的问题及解决方法
python爬虫遇到requests.exceptions.ConnectionError: HTTPSConnectionPool(host=…port=443)解决方法原创 2021-02-03 10:44:39 · 85 阅读 · 0 评论 -
【Python】requests
socat TCP-LISTEN:7788,fork TCP:192.168.0.14:9000 Python requests 我们可以检测响应状态码: r = requests.get('http://httpbin.org/get') r.status_code 为方便引用,Requests还附带了一个内置的状态码查询对象: r = requests.get('http://httpbin.org/get') print r.status_code == requests.codes.ok 如原创 2021-01-30 11:35:46 · 113 阅读 · 0 评论 -
【Python】popen
popen 通过read方法读取 p = os.popen("ping "+ host + " -w 10") # ping只读20行 line = p.read()原创 2021-01-25 09:57:31 · 61 阅读 · 0 评论 -
【Python】pytest
assert断言 用于判断实际结果和期望结果,符合预期就pass,不符合就failed。 在自动化测试中,一个用例里必须要有断言。 运行一个测试test_simple.py import pytest def func(x): return x + 1 def test_answer(): assert func(3) == 5 #assert断言 if __name__ == '__mian__': pytest.main() 测试 ➜ pytest test_simple.p原创 2021-01-19 10:36:26 · 128 阅读 · 0 评论