# pip3 install python-jenkins 不是 jenkins
import jenkins
#定义远程的jenkins master server的url,以及port
jenkins_server_url='xxxx:xxxx'
#定义用户的User Id 和 API Token,获取方式同上文
user_id='xxxx'
api_token='xxxx'
#实例化jenkins对象,连接远程的jenkins master server
server=jenkins.Jenkins(jenkins_server_u
分类标签归档:Python
python3开发笔记
1、异常打印主要信息
print('%s:%s 网络连接失败: %s!' %(service_ip, service_port, e.str()))
2、获取本文件所在目录的本地绝对路径
THIS_PATH = os.path.dirname(file)
3、简化版判断对象是否为空 if not X;
当X为None, False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()这些时,not X为真,即无法分辨出他们之间的不同。
pip3的国内安装源
方案一:临时指定安装源
1、阿里云
pip3 install -i https://mirrors.aliyun.com/pypi/simple
2、豆瓣源
pip3 install -i https://pypi.douban.com/simple requests
其他国内源:
清华:https://pypi.tuna.tsinghua.edu.cn/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinu
Python Flask中获取原始的POST正文
无论Content-Type标题如何,都可以在Python Flask中获取原始的POST正文
使用 request.get_data()获取原始数据,而不管内容类型。
数据被缓存,随后可以访问 request.data , request.json ,请求如果你先访问 request.data ,它将会自动完成。
调用带有参数的 get_data 来首先解析表单数据。
如果请求具有表单内容类型(multipart/form-data , application/x-www-form-urlencoded ,或 application/x-url-encoded),那么原始数