Python

ECHONETLiteパーサ

コード # coding:utf8 # python3.4.4 def el_parser(code): try: dict_ = {} dict_['ehd1'] = code[0:2] dict_['ehd2'] = code[2:4] dict_['tid'] = code[4:8] dict_['seoj'] = code[8:14] dict_['deoj'] = code[14:20] dict_['esv'] = code[20:22] dict_['o…

Python Tips

文字列を16進数にエンコード・デコード from binascii import hexlify, unhexlify # str -> hex def str2hex(str_): return hexlify(str_.encode('utf8')) # hex -> str def hex2str(hex_): return unhexlify(hex_).decode('utf8') UNIXタイムスタンプの取得…

ECHONETLite通信周り

コード # coding:utf8 # python3.4.4 from socket import * from time import sleep from contextlib import closing from threading import Thread from binascii import hexlify, unhexlify class ELCliant: def __init__(self): self.ip = self.get_ip() …