How can I set a single proxy for a requests session object?

In addition to @neowu' answer, if you would like to set a proxy for the lifetime of a session object, you can also do the following -

import requests
proxies = {'http': 'http://10.11.4.254:3128'}
s = requests.session()
s.proxies.update(proxies)
s.get("http://www.example.com")   # Here the proxies will also be automatically used because we have attached those to the session object, so no need to pass separately in each call

In fact, you are right, but you must ensure your defination of 'line', I have tried this , it's ok:

>>> import requests
>>> s = requests.Session()
>>> s.get("http://www.baidu.com", proxies={'http': 'http://10.11.4.254:3128'})
<Response [200]>

Did you define the line like line = ' 59.43.102.33:80', there is a space at the front of address.