python socket send 错误:TypeError: 'str' does not support the buffer interface
来源:互联网 发布:light.js 编辑:程序博客网 时间:2024/05/22 14:19
def my_post2():import http.client, urllib.parse#params = urllib.parse.urlencode({'number': 12524, 'type': 'issue', 'action': 'show'})#params = urllib.parse.urlencode({'number': 12524})#myheaders = {"User-Agent": 'iClock Proxy/1.09',"Accept": "*/*",'Connection':'close'}conn = http.client.HTTPConnection("www.baidu.com:80")#conn.request("POST", "/", params, headers)# def request(self, method, url, body=None, headers={}):#conn.request("GET", "/", params, headers)#conn.request("GET", "/", "", headers)#conn.request("GET", "/", headers=myheaders)#def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):conn.putrequest("POST", "/", skip_host=0,skip_accept_encoding=1)conn.putheader('User-Agent','iClock')conn.putheader('Connection','close')conn.putheader('Accept','*/*')conn.endheaders()conn.send('333')response = conn.getresponse()print(response.status, response.reason)conn.close()my_post2()
提示:TypeError: 'str' does not support the buffer interface,改为 conn.send(b'333') 后成功!
def my_post2():import http.client, urllib.parse#params = urllib.parse.urlencode({'number': 12524, 'type': 'issue', 'action': 'show'})#params = urllib.parse.urlencode({'number': 12524})#myheaders = {"User-Agent": 'iClock Proxy/1.09',"Accept": "*/*",'Connection':'close'}conn = http.client.HTTPConnection("www.baidu.com:80")#conn.request("POST", "/", params, headers)# def request(self, method, url, body=None, headers={}):#conn.request("GET", "/", params, headers)#conn.request("GET", "/", "", headers)#conn.request("GET", "/", headers=myheaders)#def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):conn.putrequest("POST", "/", skip_host=0,skip_accept_encoding=1)conn.putheader('User-Agent','iClock')conn.putheader('Connection','close')conn.putheader('Accept','*/*')conn.endheaders()conn.send(b'333')response = conn.getresponse()print(response.status, response.reason)conn.close()my_post2()
- python socket send 错误:TypeError: 'str' does not support the buffer interface
- Python 3 TypeError: ‘str’ does not support the buffer interface
- Python笔记002——错误TypeError: 'str' does not support the buffer interface
- TypeError:'str' does not support the buffer interface
- TypeError:’str’ does not support the buffer interface
- TypeError: 'str' does not support the buffer interface
- python3中split分割字符串出现错误 TypeError‘str’ does not support the buffer interface
- Python+client_connection.sendall(http_resp)+TypeError: 'str' does not support the buffer interface
- Python List find方法报错 TypeError: 'str' does not support the buffer interface
- python ‘str’ does not support the buffer interface解决办法
- ‘str' does not support the buffer interface
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法
- Python_bug收集_TypeError:'str' does not support the buffer interface
- python3 ‘str’ does not support the buffer interface解决方案
- 生成字典序排列(C++ STL) next_permutation函数
- 文件读写(结构体)
- 共享池,java池,大型池,PGA,SGA 笼统概念
- java 集合 差集 交集 合集 retain
- 西藏日记:2013年3月12日 周二 多云
- python socket send 错误:TypeError: 'str' does not support the buffer interface
- MFC : 欢迎界面
- 跨平台移动开发实战
- 进一步了解const指针
- 关于Outlook.pst被删掉之后的解决办法
- 用OpenGL ES绘制一个红色三角形(二)
- 移动web设计&开发45个实用指南
- java中一些值得注意的命名规范
- Ural 1019 Line Painting