import uuid
def MyRound(x):
return 2 * ((x.bit_length() // 8) + (x.bit_length() % 8 > 0))
def main():
ByteList = [0xCC, 0xC2, 0x8A, 0x87, 0x43, 0x53, 0xF2, 0x46, 0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA]
x = uuid.UUID(bytes_le = str(bytearray(ByteList)))
print x
print 'GUID("%s")' % str(x).upper()
print ' '
x = uuid.UUID('{236A7970-5B07-442B-93DB-327400E96CFA}')
x = uuid.uuid4()
print x
print 'GUID("%s")' % str(x).upper()
strList = bytearray(x.get_bytes_le())
print '{%s}' % ', '.join(['0x%02x' % i for i in strList])
strList = list(x.get_fields()[0:5])
strList.extend(long(i) for i in bytearray(x.get_bytes_le()[10:]))
print '{%s}' % ', '.join(['0x%0*x' % (MyRound(i), i) for i in strList])
Str = '{{0x{0[0]:08x}, 0x{0[1]:04x}, 0x{0[2]:04x}, {{'.format(x.get_fields())
Str += ', '.join(['0x%02x' % i for i in bytearray(x.get_bytes_le()[8:])]) + '}}'
print Str
if __name__ == '__main__':
main()
#
# http://code.google.com/p/pyscripter/
# http://sourceforge.net/projects/pyscripter/files/?source=navbar
2015年4月11日 星期六
GUID 產生器
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言