requests.exceptions.InvalidHeader: Invalid return character or leading space in header: User-Agent错误

requests.exceptions.InvalidHeader: Invalid return character or leading space in header: User-Agent错误

原因是分号后面的双引号多了个空格

多个空格的headers头

headers = {
"User-Agent":" Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
}

正确headers头

headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36"
}




  上一篇:pip豆瓣安装源下载库文件 下一篇:github超时解决  

湘ICP备19016894号 © 2019 小钱