随笔分类 -  python

摘要:eval函数就是实现list、dict、tuple与str之间的转化str函数把list,dict,tuple转为为字符串# 字符串转换成列表a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]"print(type(a))b = eval(a)print(b) # 字符串转换成字典a = "{1: 'a', 2: 'b'}"print(type(a))b = eva... 阅读全文
posted @ 2018-12-11 13:37 致橡树的你 阅读(4974) 评论(1) 推荐(0)
摘要:整理了一下前面3期学的内容后,现在练习使用python去操作数据库 阅读全文
posted @ 2018-12-01 22:25 致橡树的你 阅读(492) 评论(0) 推荐(0)
摘要:HTML报告展示 1. 需要HTML Publisher plugin插件 2. 在workspace下的工程(构建)中的目录中存储测试报告 在Jenkins中新建一个job,进入配置项。 首先通过pytest生成测试报告 pytest执行测试 注,py.test执行测试后生成报告,会生成在work 阅读全文
posted @ 2018-11-18 00:25 致橡树的你 阅读(7104) 评论(2) 推荐(1)
摘要:原文出处:https://www.cnblogs.com/hushaojun/p/4533241.html >>> import os >>> os.path.exists('d:/assist') True >>> os.path.exists('d:/assist/getTeacherList. 阅读全文
posted @ 2018-11-11 13:29 致橡树的你 阅读(57570) 评论(0) 推荐(2)
摘要:url = “http://abad.com”header = { "user-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3423.2 阅读全文
posted @ 2018-11-06 16:22 致橡树的你 阅读(1296) 评论(0) 推荐(0)
摘要:本文出处:https://www.cnblogs.com/goodhacker/p/3355660.html#undefined python的标准库里的日志系统从Python2.3开始支持。只要import logging这个模块即可使用。如果你想开发一个日志系统, 既要把日志输出到控制台, 还要 阅读全文
posted @ 2018-06-19 20:34 致橡树的你 阅读(1390) 评论(0) 推荐(0)
摘要:知识扩展: 1.需要安装的库Pillow 库(PIL)和pytesseract ,安装方式直接通过pip安装 2.需要安装windows版本的TesseractOCRiOS(光学字符识别)程序,下载地址:http://xza.198424.com/tesserract.zip 特别注意,ocr安装完 阅读全文
posted @ 2018-05-31 14:20 致橡树的你 阅读(5869) 评论(0) 推荐(0)
摘要:使用格式化字符串的方式实现举例: re.findall("(this,%s,'(.*?)'"%str(i),"abcd(this,1,'123123)')这里i为变量 阅读全文
posted @ 2018-05-27 03:47 致橡树的你 阅读(1463) 评论(0) 推荐(0)
摘要:#encoding:utf-8import math #向上取整print "math.ceil "print "math.ceil(2.3) => ", math.ceil(2.3)print "math.ceil(2.6) => ", math.ceil(2.6) #向下取整print "\nm 阅读全文
posted @ 2018-05-27 02:01 致橡树的你 阅读(452) 评论(0) 推荐(0)
摘要:import requests res = requests.get(url) cookies = requests.utils.dict_from_cookiejar(res.cookies) print(cookies[key]) 阅读全文
posted @ 2018-05-25 17:55 致橡树的你 阅读(11006) 评论(0) 推荐(0)
摘要:问题: 使用Python3 requests发送HTTPS请求,已经关闭认证(verify=False)情况下,控制台会输出以下错误: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate 阅读全文
posted @ 2018-05-25 14:52 致橡树的你 阅读(1880) 评论(0) 推荐(1)
摘要:json.dumps 是将python的数据类型进行json的编码,生成json格式的数据,举例json_data = json.dumps(str) str为python的字符串类型数据,生成的json_data为json编码格式的数据 json.loads 是将json数据类型的数据解析成 py 阅读全文
posted @ 2018-05-10 16:40 致橡树的你 阅读(362) 评论(0) 推荐(0)
摘要:一般我们使用python的第三方库requests及框架scrapy来爬取网上的资源,但是设计javascript渲染的页面却不能抓取,此 时,我们使用web自动化测试化工具Selenium+无界面浏览器PhantomJS来抓取javascript渲染的页面,下面实现一个简单的爬取 环境搭建 准备工 阅读全文
posted @ 2018-04-20 00:45 致橡树的你 阅读(1486) 评论(0) 推荐(0)
摘要:正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串、将匹配的子串做替换或者从某个串中取出符合某个条件的子串等。 列目录时, dir *.txt或ls *.txt中的*.txt就不是一个正则表达式,因为这里*与正则式的*的含义是不同的。 正 阅读全文
posted @ 2018-04-09 00:14 致橡树的你 阅读(486) 评论(0) 推荐(0)
摘要:数据库 增 use db1 #有则切换,无则新增 查 show dbs #查看所有 db #当前 删 db.dropDatabase() 集合: 增: db.user db.user.info db.user.auth 查看 show collections show tables 删 db.use 阅读全文
posted @ 2018-04-03 19:55 致橡树的你 阅读(722) 评论(0) 推荐(0)
摘要:解决办法: 例子: 原来的xpath为: user=selector.xpath('//*[@id="Con"]/tr[1]/th/text()') 例子: 原来的xpath为: user=selector.xpath('//*[@id="Con"]/tr[1]/th/text()') 修改后: 阅读全文
posted @ 2018-04-01 23:48 致橡树的你 阅读(8454) 评论(0) 推荐(0)
摘要:XPath轴(XPath Axes)可定义某个相对于当前节点的节点集: 1、child 选取当前节点的所有子元素 2、parent 选取当前节点的父节点 3、descendant 选取当前节点的所有后代元素(子、孙等) 4、ancestor 选取当前节点的所有先辈(父、祖父等) 5、descenda 阅读全文
posted @ 2018-04-01 13:39 致橡树的你 阅读(16438) 评论(1) 推荐(1)
摘要:问题描述 当前环境win10,python_3.6.1,64位。 在windows下,在dos中运行pip install Scrapy报错: 解决方案 http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 下载twisted对应版本的whl文件(如我 阅读全文
posted @ 2018-03-18 02:54 致橡树的你 阅读(8430) 评论(1) 推荐(2)
摘要:Python中的mysql操作可以使用MySQLdb模块来完成。它符合Python社区设计的Python Database API SpecificationV2.0标准,所以与其他的数据库操作的API,如SQLite等基本类似。 学习可参见:http://www.runoob.com/python 阅读全文
posted @ 2018-03-05 16:59 致橡树的你 阅读(562) 评论(0) 推荐(0)
摘要:其中: filepath为文件的目录,即D:/test filename为文件的名字,即test extension为文件的扩展名,即.py filepath为文件的目录,即D:/test filename为文件的名字,即test extension为文件的扩展名,即.py 阅读全文
posted @ 2018-02-26 17:42 致橡树的你 阅读(25518) 评论(0) 推荐(1)