util.py 334 B

1234567891011121314151617181920
  1. # -*- coding: utf-8 -*-
  2. """
  3. :copyright: ©2018 by IPIP.net
  4. """
  5. import sys
  6. def bytes2long(a, b, c, d):
  7. return convert(a) << 24 | convert(b) << 16 | convert(c) << 8 | convert(d)
  8. def convert(v):
  9. if v == "" or v == 0:
  10. return 0
  11. if sys.version_info.major >= 3:
  12. return v
  13. else:
  14. return ord(v)