回答編集履歴

1

追記

2016/08/22 13:46

投稿

sharow
sharow

スコア1149

test CHANGED
@@ -19,3 +19,31 @@
19
19
  print(conv_hbase_str(s))
20
20
 
21
21
  ```
22
+
23
+
24
+
25
+ -- 追記
26
+
27
+ [ast.literal_eval](http://docs.python.jp/3/library/ast.html#ast.literal_eval)というのがあり、評価がリテラルに限られるのでこちらの方が多少安全なようです。
28
+
29
+
30
+
31
+ ```python3
32
+
33
+ # -*- coding: utf-8 -*-
34
+
35
+ from ast import literal_eval
36
+
37
+
38
+
39
+ def conv_hbase_str(s):
40
+
41
+ return literal_eval('b"{}"'.format(s)).decode()
42
+
43
+
44
+
45
+ s = '\\xE3\\x83\\x86\\xE3\\x82\\xB9\\xE3\\x83\\x88'
46
+
47
+ print(conv_hbase_str(s))
48
+
49
+ ```