[Tutor] Send Hex

Григор grigor.kolev at gmail.com
Fri Dec 18 15:34:30 CET 2009


Hi
Can I send date and time like Hex in to the Serial port or file.

------------------------------------
from time import *
def TimeMake():
    '''Formating time and data (dd-mm-yy hh:mm) and change it like ASCII'''
    Time=list(localtime())  #get Time and Date
    Time[0]=str(Time[0])    #Make (yy) str
    Time = '%02d-%02d-%s %02d:%02d' % (Time[2], Time[1], Time[0][2:],
Time[4], Time[5]) #Formating (dd-mm-yy hh:mm)
    TimeHex = []
    for i in Time:      #Take ASCII
        TimeHex.append(ord(i))
    Time =[]
    for i in TimeHex:       #Make ASCII in hex format
        Time.append(hex(i))
    return Time
Time=TimeMake()
#When I write it in the some file is a string but must to be like hex
------------------------------------

-- 
Криле имат само тия, дето дето сърцето им иска да лети !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091218/56218c20/attachment.htm>


More information about the Tutor mailing list