!!!エンコードされて16進数になっている文字列をデコードする *投稿者: みゅ *カテゴリ: Python *優先度: 普通 *状態: 完了 *日時: 2010年07月21日 10時56分11秒 //{{bugstate}} !!内容 *メモ hexStr = re.compile('\\\\x(..?)|([0-9A-Za-z^`_\[\]\|{}@~!"#\$%&\'=\-]|\\\\?)') def _trans(self, txt, charset='sjis'): aa = hexStr.findall(txt) aaa = '' for m in aa: if m[1] != '': aaa = aaa + m[0] + re.sub('0x','',hex(ord(m[1]))) else: aaa = aaa + m[0] bbb = aaa.decode("hex").decode(charset) return urllib.unquote_plus(bbb) !!コメント //{{comment}}