proxy.py 577 B

123456789101112131415161718192021222324252627282930
  1. from attr import attrs, attr
  2. @attrs
  3. class Proxy(object):
  4. """
  5. proxy schema
  6. """
  7. host = attr(type=str, default=None)
  8. port = attr(type=int, default=None)
  9. def __str__(self):
  10. """
  11. to string, for print
  12. :return:
  13. """
  14. return f'{self.host}:{self.port}'
  15. def string(self):
  16. """
  17. to string
  18. :return: <host>:<port>
  19. """
  20. return self.__str__()
  21. if __name__ == '__main__':
  22. proxy = Proxy(host='8.8.8.8', port=8888)
  23. print('proxy', proxy)
  24. print('proxy', proxy.string())