0
ユニコード文字列の制御文字だけをエスケープする方法を示します。python2モジュールのユニコードでのエスケープ制御文字
control_chars = [unichr(c) for c in range(0x20)] # you may extend this as required
def control_escape2(s):
return u''.join([c.encode('unicode_escape') if c in control_chars else c for c in s])
Which is the correct way to encode escape characters in Python 2 without killing Unicode?
これは、私はいつも周りに同じコードをコピーする必要がないようにモジュールを入れておくとよいかもしれ特徴であると聞こえます。既存のPythonモジュールにこれのようなものはありますか?
希望する変換の前後の例を教えてください。 –
あなたのリンクされた質問への答えの1つはこう書いています: "*これはpython stdlibでこれを行う方法がありますが、そうではありません。私はバグレポートを提出しました:http://bugs.python.org/issue18679* " –