954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to represent sequence of bytes

Hello,

I'm trying to represent the system date in a sequence such as:
dd mm yy yy

So far i got:
dd mm yyy

so, the year is represented on 2 ytes, but I only have 3 characters, i need to split after the first character and then add a zero in from of the first character.

for example 2012 in hex = 7dc

I need to turn it in
07 DC

I could not find anything regardin spliting without a separator...
Any help is apreciated :)

Malraux
Newbie Poster
4 posts since Jan 2012
Reputation Points: 10
Solved Threads: 0
 
>>> def split_hex(n):
	print '%02x %02x' % divmod(n, 256)
	print '%c%c' % divmod(n,256)
	return '%c%c' % divmod(n,256)

>>> split_hex(2012)
07 dc
Ü
'\x07\xdc'
>>>
pyTony
pyMod
Moderator
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: