先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7
深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新软件测试全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
如果你需要这些资料,可以添加V获取:vip1024b (备注软件测试)
正文
在该环境下安装
pip install tabulate
前言
本篇博客是python开发的使用案例博客,结合一些具体的案例进行阐述,本篇博客主要内容是使用Python发送Get请求,模拟http请求,后面可以搞个爬虫出来,另外就是如何使用Python进行SSH连接服务器。
其他相关的博客文章如下:
目录
引出
1.使用Python发送Get请求,模拟http请求;
2.如何使用Python进行SSH连接服务器;
python发送get请求
案例1:get请求,间隔1分钟查询,if语法打印
import requests
import time
from datetime import datetime
url=f’http://x.x.x.x:8082/sn’ #格式化输出拼接
snTarget = “S231012J0029”
while(True):
response = requests.get(url=url)
snList = response.json()
current_time = datetime.now()
if snTarget in snList:
print(“%s 查询到目标sn” %current_time)
else:
print(“%s 未查到设备sn” %current_time)
time.sleep(60)
案例2:间隔一定时间,轮流进行get请求,总共2个
encoding:utf-8
import requests
import time
from datetime import datetime
req3 = “http://xxxx”
req4 = “http://xxxx”
reqs = [req3, req4]
vers = [“2.0.3”, “2.0.4”]
url = f’http://x.x.x.x:8082/sn’ # 格式化输出拼接
snTarget = “S231012J0029”
while (True):
response = requests.get(url=url)
snList = response.json()
current_time = datetime.now()
if snTarget in snList:
print(“%s 查询到目标sn” % current_time)
for ver, req in zip(vers, reqs):
print(“{} 进行版本升级 {}”.format(datetime.now(), ver))
print(“send request :”, req)
resp = requests.get(url=req).json()
print(resp)
time.sleep(430)
else:
print(“%s 未查到设备sn” % current_time)
time.sleep(60)
python进行SSH链接
建立SSH连接核心程序
import paramiko
from paramiko.client import SSHClient
import time
import logging
import utils.LogUtils
设置日志日期格式
logging.basicConfig(format=‘%(asctime)s - %(levelname)s - %(message)s’, level=logging.DEBUG)
main主方法
def ssh_hi(client: SSHClient):
执行命令
stdin, stdout, stderr =
client.exec_command(“grep -E ‘RegSWVersion|onResponse’ /root/logs/sys-debug.log |grep -v 1.1 | tail -n 1”)
打印命令输出
resp = stdout.read().decode()
logging.info(resp)
if “2.0.4” in resp:
logging.warning(“当前版本为2.0.4, 版本改为2.0.3”)
elif “2.0.3” in resp:
logging.warning(“当前版本为2.0.3, 版本改为2.0.4”)
else:
logging.warning(“需要上位机刷新版本”)
关闭连接
def closeSSH(client: SSHClient):
client.close()
建立连接
def buildSSH():
创建SSH客户端
client = paramiko.SSHClient()
自动添加主机名和密钥到本地的known_hosts文件
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
连接SSH服务器
client.connect(‘ip’, port=22, username=‘username’, password=‘password’)
return client
if name == ‘__main__’:
ssh = buildSSH()
while(True):
ssh_hi(ssh)
time.sleep(120)
closeSSH(ssh)
日志打印附件
#!/usr/bin/env python
encoding: utf-8
import logging
now we patch Python code to add color support to logging.StreamHandler
def add_coloring_to_emit_windows(fn):
add methods we need to the class
def _out_handle(self):
import ctypes
return ctypes.windll.kernel32.GetStdHandle(self.STD_OUTPUT_HANDLE)
out_handle = property(_out_handle)
def _set_color(self, code):
import ctypes
Constants from the Windows API
self.STD_OUTPUT_HANDLE = -11
hdl = ctypes.windll.kernel32.GetStdHandle(self.STD_OUTPUT_HANDLE)
ctypes.windll.kernel32.SetConsoleTextAttribute(hdl, code)
setattr(logging.StreamHandler, ‘_set_color’, _set_color)
def new(*args):
FOREGROUND_BLUE = 0x0001 # text color contains blue.
FOREGROUND_GREEN = 0x0002 # text color contains green.
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注软件测试)
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**
需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注软件测试)
[外链图片转存中…(img-KMDL22Bw-1713355680128)]
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!