问题
from win32com.client import Dispatch
winhttp = Dispatch('winhttp.winhttprequest.5.1')
print winhttp.Option(6) #True
winhttp.Option(6) = False #SyntaxError <----------------how to set Option(6) to false
print winhttp.Option(6)
winhttp.Open('GET', 'http://google.com', False)
winhttp.Send()
print winhttp.responsetext
===========================================
output:
invalid syntax: winhttp.py, line 13, pos 11 File "c:\Users\***\Desktop\winhttp.py", line 13, in ? set winhttp.Option(6) = False
how to do it? many thanks!
回答1:
This should work:
winhttp.SetOption(6, False)
Unless you have some really good reason for using winhttprequest, I'd use something out of the Python standard library, or better yet install the requests library. You will find these options much easier to deal with.
来源:https://stackoverflow.com/questions/14417539/python-win32com-how-to-set-winhttp-option-value