![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
悠悠做神仙
这是一趟开往测试架构师的列车,请系好安全带,触发~
展开
-
Python之禅
>>> import this The Zen of Python, by Tim PetersBeautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Fla...翻译 2018-11-27 10:32:01 · 98 阅读 · 0 评论 -
python使用 pip时报错:Fatal error in launcher: Unable to create process using……处理
在一个系统中共存Python2、python3的时候,pip、pip2、pip3使用的时候会报错:Fatal error in launcher: Unable to create process using '"',找到对应的scrpts目录下如果没有安装,需要先安装一下,然后看提示,有些已安装的报错,多半是版本问题,可以更新一下即可原创 2020-01-07 13:42:12 · 2664 阅读 · 1 评论 -
pycharm做一些个性化配置, 自动添加头注释,比如时间,作者信息等
File->settings->Editor->File and Code Templates->Python Script#!/usr/bin/env python# -*- coding: utf-8 -*-# @Time : ${DATE} ${TIME}# @Author : XXX# @Site : ${SITE}# @File : ${NAME}....原创 2019-07-15 17:32:52 · 1161 阅读 · 0 评论 -
Selenium 中ExpectedConditions 用法说明(最全整理)
注:从原文档一个个扒出来翻译的,有不对的地方还请批评指正。1、 titleIs( String title)判断当前页面的title是否精确等于预期2、 titleContains( String title)判断当前页面的title是否包含预期字符串3、 urlToBe( String url)判断当前页面的url是否精确等于预期4、 urlContains( String ...原创 2019-01-02 09:26:52 · 17614 阅读 · 4 评论 -
selenium模块(九):项目练习
自动登录163邮箱并发送邮件#注意:网站都策略都是在不断变化的,精髓在于学习流程。下述代码生效与2017-11-7,不能保证永久有效from selenium import webdriverfrom selenium.webdriver import ActionChainsfrom selenium.webdriver.common.by import Byfrom selenium...转载 2018-11-30 17:01:06 · 239 阅读 · 0 评论 -
selenium模块(八):异常处理
异常处理from selenium import webdriverfrom selenium.common.exceptions import TimeoutException,NoSuchElementException,NoSuchFrameExceptiontry: browser=webdriver.Chrome() browser.get('http://www...转载 2018-11-30 16:59:07 · 949 阅读 · 0 评论 -
selenium模块(七):cookies、选项卡管理
cookiesfrom selenium import webdriverbrowser=webdriver.Chrome()browser.get('https://www.zhihu.com/explore')#获取cookiesprint(browser.get_cookies())#添加cookiesbrowser.add_cookie({'k1':'xxx','k2'...原创 2018-11-30 16:57:10 · 213 阅读 · 0 评论 -
selenium模块(六):模拟浏览器前进和后退
模拟浏览器的前进后退import timefrom selenium import webdriverbrowser=webdriver.Chrome()browser.get('https://www.baidu.com')browser.get('https://www.taobao.com')browser.get('http://www.sina.com.cn/')#后退...转载 2018-11-30 16:52:33 · 928 阅读 · 0 评论 -
selenium模块(五):元素交互操作
点击、清空from selenium import webdriverfrom selenium.webdriver import ActionChainsfrom selenium.webdriver.common.by import By #按照什么方式查找,By.ID,By.CSS_SELECTORfrom selenium.webdriver.common.keys import ...转载 2018-11-30 16:49:37 · 934 阅读 · 0 评论 -
selenium模块(四):等待元素被加载
1、selenium只是模拟浏览器的行为,而浏览器解析页面是需要时间的(执行css,js),一些元素可能需要过一段时间才能加载出来,为了保证能查找到元素,必须等待2、等待的方式分两种:隐式等待:在browser.get(‘xxx’)前就设置,针对所有元素有效显式等待:在browser.get(‘xxx’)之后设置,只针对某个元素有效#隐式等待:from selenium import w...转载 2018-11-30 16:43:09 · 1629 阅读 · 0 评论 -
selenium模块(三):三种选择器(id、css、xpath)
三种查找元素方式 :id、css、xpath最常用xpath,css更灵活。from selenium import webdriverfrom selenium.webdriver import ActionChainsfrom selenium.webdriver.common.by import By #按照什么方式查(By.ID,By.CSS_SELECTOR)from sel...转载 2018-11-30 16:32:45 · 2026 阅读 · 0 评论 -
selenium模块(二):基本使用
引入相关模块(import),利用浏览器驱动,模拟操作 。from selenium import webdriverfrom selenium.webdriver import ActionChainsfrom selenium.webdriver.common.by import By #按照什么方式查找,By.ID,By.CSS_SELECTORfrom selenium.webdr...转载 2018-11-30 16:28:03 · 162 阅读 · 0 评论 -
selenium模块(一):介绍及安装
一、介绍selenium最初是一个自动化测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题。selenium本质是通过驱动浏览器,完全模拟浏览器的操作,比如跳转、输入、点击、下拉等,来拿到网页渲染之后的结果,可支持多种浏览器from selenium import webdriverbrowser=webdriver.Chrome()brow...转载 2018-11-30 16:25:25 · 788 阅读 · 0 评论 -
Python3.x操作数据库Mysql--接入篇
(来自菜鸟教程)连接数据库前,请先确认以下事项:1、您已经创建了数据库 TESTDB. 在TESTDB数据库中您已经创建了表 EMPLOYEE2、EMPLOYEE表字段为 FIRST_NAME, LAST_NAME, AGE, SEX 和 INCOME。3、连接数据库TESTDB使用的用户名为 “testuser” ,密码为"test123",你可以可以自己设定或者直接使用root用户名及...原创 2018-11-27 15:31:04 · 919 阅读 · 0 评论 -
Python操作数据库mysql服务--安装篇
目前,Python分为2.x和3.x版本,根据不同的版本,装不同的Mysql服务。1、Python 2.x版本安装(MySQLdb)MySQLdb 是用于Python链接Mysql数据库的接口,它实现了 Python 数据库 API 规范 V2.0,基于 MySQL C API 上建立的。为了用DB-API编写MySQL脚本,必须确保已经安装了MySQL。复制以下代码,并执行:#!/usr...原创 2018-11-27 13:28:36 · 185 阅读 · 0 评论 -
python3 获取文件的上一级目录
from os.path import realpath, dirname# 获取当前文件的全路径名file_path = os.path.realpath(__file__)# 上一级目录parent_dir = os.path.dirname(file_path)# 上上级目录parent_dir = os.path.dirname(os.path.dirname(file_...转载 2019-07-22 13:29:09 · 3770 阅读 · 0 评论