python 中文转字节序列

[AFA]/usr/afa>cat tsbyte.py     
# !/usr/bin/env python
# -*- coding: gbk -*-
a='成功'
print a.encode('string_escape')
[AFA]/usr/afa>
[AFA]/usr/afa>python tsbyte.py
\xb3\xc9\xb9\xa6
[AFA]/usr/afa>python
Python 2.7.2 (default, Jan  1 2012, 19:35:59) [C] on aix6
Type "help", "copyright", "credits" or "license" for more information.
>>> print '\xb3\xc9\xb9\xa6'
成功

猜你喜欢

转载自blog.csdn.net/zhaoyangjian724/article/details/89305382