您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

34 行
698 B

  1. #
  2. # This file is part of pyasn1 software.
  3. #
  4. # Copyright (c) 2005-2019, Ilya Etingof <etingof@gmail.com>
  5. # License: http://snmplabs.com/pyasn1/license.html
  6. #
  7. from sys import version_info
  8. if version_info[0:2] < (2, 6):
  9. def bin(value):
  10. bitstring = []
  11. if value > 0:
  12. prefix = '0b'
  13. elif value < 0:
  14. prefix = '-0b'
  15. value = abs(value)
  16. else:
  17. prefix = '0b0'
  18. while value:
  19. if value & 1 == 1:
  20. bitstring.append('1')
  21. else:
  22. bitstring.append('0')
  23. value >>= 1
  24. bitstring.reverse()
  25. return prefix + ''.join(bitstring)
  26. else:
  27. bin = bin