(EC2)价格抓取demo '''#想使用select方法,但是代码里不是select表单元素,而是awsui-select元素,故放弃select_2 = Select(dr.find_element_by_xpath('//*[@id="e-c2next"]/div/div[2]/awsui-form/div/div[2]/span/span/div[2]/div/div/div[1]/div[2]/div/div[2]/span[3]/awsui-table/div/div[2]/div/div[2]/span/div/d
使用openpyxl库打开表时,tionWarning: Call to deprecated function get_sheet_by_name (Use wb[sheetname]) 使用openpyxl库时,打开表操作中遇到如下报错:DeprecationWarning: Call to deprecated function get_sheet_by_name (Use wb[sheetname])可将sheet.get_sheet_by_name('name')替换成sheet['name']方可解决
demo #!/usr/bin/env python# -*- coding:utf-8 -*-# author: Frank time:2020/8/21import pymysqlclass Mysql: def __init__(self,host,port,user,passwd,db): self.content = pymysql.Connect( host=host, # mysql的主机ip port=port,
python连接远程mysql程序demo 先上demo:#!/usr/bin/env python # -*- coding:utf-8 -*-# author: Frank time:2020/8/21import pymysqlclass Mysql: def __init__(self): self.content = pymysql.Connect( host='X.X.X.X', # mysql的主机ip port=3306, # 端口
连接远程mysql时遇到的问题详解 遇到问题:web项目连接远程(服务器)mysql 2003错误连接超时连接mysql数据库时抛出pymysql.err.OperationalError解决办法:第一步:修改mysql配置文件让其他主机可以访问mysql服务例如:[mysqld]character-set-server = utf8bind-address = 0.0.0.0port = 3306配置文件在/etc/my.cnf.d/mysql-server.cnf查找一下命令为:find / -name mysql-se
python+selenium常用方法封装 demo如下:#encoding=utf-8from selenium import webdriverfrom Util.KeyBoardUtil import KeyBoardKeysfrom Util.ClipboardUtil import Clipboardimport time#定义全局变量driverdriver = Nonedef open(browserName): #打开浏览器 global driver,waitUtil try:
python+selenium获取元素and显示等待的方法封装 获取元素的demo如下:from selenium.webdriver.support.ui import WebDriverWaitimport timefrom selenium import webdriver#获取单个页面元素对象def getElement(driver,localtorType,localtorExpression): try: element = WebDriverWait(driver,5).until(lambda x:x.find_el
python+selenium封装excel关键字 先上demo#encoding=utf-8import openpyxlfrom openpyxl.styles import Border, Side, Fontimport timeclass ParseExcel(object): def __init__(self): self.workbook = None self.excelFile = None self.font = Font(color = None) # 设置字体的颜
pip安装时总是timeout的办法 在安装软件的时候,指定源的位置,一般用阿里云的源,阿里云: https://mirrors.aliyun.com/pypi/simple/中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/豆瓣(douban) :https://pypi.douban.com/simple/清华大学: https://pypi.tuna.tsinghua.edu.cn/simple/中国科学技术大学:https://pypi.mirrors.ustc.edu.cn/si
Python中关于time的封装使用 demo#!/usr/bin/env python# -*- coding:utf-8 -*-# author: Frank time:2020/8/9import timeimport datetimeimport locale# 获取当前的日期def get_current_date(): time_tup = time.localtime() current_date = str(time_tup.tm_year) + "年" + str(time_tup.tm
Python中一种更好看的测试报告BeautifulReport 先上demoimport unittestfrom BeautifulReport import BeautifulReport as bf #导入BeautifulReport模块,这个模块也是生成报告的模块,但是比HTMLTestRunner模板好看class XXX(unittest.TestCase) def setup() pass def test_1() print('第1个用例') def test_2() print('第2个用例') def test_3()
Python中email模块的封装使用 先上demo:from email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom email.mime.image import MIMEImagefrom email.header import Headerfrom time import strftime, localtime ,sleepdef send_email(dest_email,file_path,report_name,
Python中单独打印“\” 填写路径时有时需要输入‘\’,但是单独打印不出’’print(’’) 报错:SyntaxError: EOL while scanning string literal正确打印方式:print(’\’)
selenium中键盘、鼠标、表单操作 键盘操作#!/usr/bin/env python # -*- coding:utf-8 -*- from selenium import webdriver # 要想调用键盘按键操作需要引入keys包from selenium.webdriver.common.keys import Keys #创建浏览器对象driver = webdriver.Firefox() driver.get("http://www.baidu.com") #打印页面标题“百度一下你就知道”print