반응형
urllib2
는 DELETE 또는 PUT 메소드를 지원합니까? 그렇다면 예를 들어주세요. 피스톤 API를 사용해야합니다.
해결 방법
import httplib
conn = httplib.HTTPConnection('www.foo.com')
conn.request('PUT', '/myurl', body)
resp = conn.getresponse()
content = resp.read()
import urllib2
opener = urllib2.build_opener(urllib2.HTTPHandler)
request = urllib2.Request('http://example.org', data='your_put_data')
request.add_header('Content-Type', 'your/contenttype')
request.get_method = lambda: 'PUT'
url = opener.open(request)
참조 페이지 https://stackoverflow.com/questions/4511598
반응형
'파이썬' 카테고리의 다른 글
파이썬 Axes 클래스-지정된 단위로 축의 크기 (너비 / 높이)를 명시 적으로 설정합니다. (0) | 2020.10.17 |
---|---|
파이썬 줄 바꿈없이 인쇄 ( 'a'로 인쇄)하면 공백이 인쇄됩니다. 제거하는 방법은 무엇입니까? (0) | 2020.10.17 |
파이썬 Python 스크립트 컴파일 (실행하지 않음) (0) | 2020.10.17 |
파이썬 사전을 문자열로 변환하고 다시 (0) | 2020.10.17 |
파이썬 Write a program to find sum of two numbers using functions and calculate their average? (0) | 2020.10.17 |
댓글