![](/img/trans.png)
[英]python how to convert Special string u'\x08' u'\x09' u'\x03' to 8 9 3
[英]How to convert “\x09” back to tab
我正在從Python中讀取一行內容:
#separator \x09
如何將\\x09
轉換為制表符(以后將用作定界符)?
>>> s = r'\x09'
>>> s.decode('unicode_escape')
u'\t'
或者,在Python 3.x中(如果您擁有str
而不是bytes
,因為您無法decode
str
):
>>> s = r'\x09'
>>> s.encode('unicode_escape').decode('unicode_escape')
>>> '\t'
有關詳細信息,請參見codecs
文檔中的Python特定編碼 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.