|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
为什么都是\n呢,我想要的是换行,全是\n的话看着不整齐,鱼油们有办法吗?
代码
- import urllib.request
- import urllib.parse
- data = bytes(urllib.parse.urlencode({'word':'hello'}),encoding = 'utf8')
- response = urllib.request.urlopen('http://httpbin.org/post',data = data)
- result = response.read()
- print(result)
复制代码
结果
- b'{\n "args": {}, \n "data": "", \n "files": {}, \n "form": {\n "word": "hello"\n }, \n "headers": {\n "Accept-Encoding": "identity", \n "Content-Length": "10", \n "Content-Type": "application/x-www-form-urlencoded", \n "Host": "httpbin.org", \n "User-Agent": "Python-urllib/3.8", \n "X-Amzn-Trace-Id": "Root=1-5efc4f00-4c81d9f05a163a60b9f23ab0"\n }, \n "json": null, \n "origin": "39.162.148.8", \n "url": "http://httpbin.org/post"\n}\n'
复制代码
图片
- print(result.decode('utf-8'))
复制代码
|
|