Go Back   Champions of Regnum > Español > La Taberna

La Taberna Un lugar para conversar sobre casi cualquier tema

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old 07-05-2009, 06:48 PM   #11
ArcticWolf
Duke
 
ArcticWolf's Avatar
 
Join Date: Nov 2006
Location: 0x00CAFE
Posts: 3,366
ArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of lightArcticWolf is a glorious beacon of light
Default

Otra:
Code:
import numpy
class binParser:
    def __init__(self, binlength=8, space=True, encodeSpace=True):
        self.binlen=binlength
        self.trailingspace=space
        self.encodeSpace=encodeSpace
    
    def toBin(message):
        result = ""
        for char in message:
            if self.encodeSpace==False and char==" ": break
            result += numpy.binary_repr(ord(char),self.binlen)
            if self.trailingspace: result += " "
        return result

    def fromBin(message):
        result=""
        splitList = message.split()
        for binChar in splitList:
            result += chr(int(binchar,2))
        return result      
    
if __name__ == "__main__":
    parser = binParser()
    print "test:", parser.fromBin(parser.toBin("test"))
__________________
I don't have a solution, but I admire the problem.
ArcticWolf no ha iniciado sesión   Reply With Quote
 

Tags
charlar, saludar


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:00 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
NGD Studios 2002-2024 © All rights reserved