pyqt5 QThread发送http请求出错: No connection adapters were found for

目的:

从config.ini读取网址,使用request进行访问,post数据

遇到问题:

requests.exceptions.InvalidSchema: No connection adapters were found for ''https://httpbin.org/post''

原因:config解析的时候默认以字符串的形式读取内容,即会在所读取的内容外面包两个单引号( ' )

错误:
[http]
URL_GET_OPERATOR = 'https://api.github.com/events'
URL_POST_DATA = 'https://httpbin.org/post'


正确:
[http]
URL_GET_OPERATOR = https://api.github.com/events
URL_POST_DATA = https://httpbin.org/post

解决方案:

1.在读取部分添加一层eval()

url = eval(config.get("http", "URL_POST_DATA"))

2.在写配置文件的时候,就不要加单引号了,习惯了。。。。。。。。

上一篇:IntelliJ IDEA 自带的 HTTP Client 接口调用插件,吊打 Postman


下一篇:『居善地』接口测试 — 6、Httpbin服务介绍