python - How to covert this binary string to a normal string? -


i have binary string , trying convert normal string.

[b'\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe4\xb8\xad\xe5\x9b\xbd\xe9\xa2\x86\xe5\x85\x88\xe7\x9a\x84\xe5\xae\x9e\xe5\x90\x8d\xe5\x88\xb6sns\xe7\xa4\xbe\xe4\xba\xa4\xe7\xbd\x91\xe7\xbb\x9c\xe3\x80\x82\xe5\x8a\xa0\xe5\x85\xa5\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe6\x89\xbe\xe5\x88\xb0\xe8\x80\x81\xe5\x90\x8c\xe5\xad\xa6\xef\xbc\x8c\xe7\xbb\x93\xe8\xaf\x86\xe6\x96\xb0\xe6\x9c\x8b\xe5\x8f\x8b\xe3\x80\x82'] 

there no normal string mode,string encoding, , string in encoded, based on terminal decoding or custom decoding can real string.

as default encoding of terminal utf-8,it decode string utf-8 encoding , print result :

>>> s=[b'\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe4\xb8\xad\xe5\x9b\xbd\xe9\xa2\x86\xe5\x85\x88\xe7\x9a\x84\xe5\xae\x9e\xe5\x90\x8d\xe5\x88\xb6sns\xe7\xa4\xbe\xe4\xba\xa4\xe7\xbd\x91\xe7\xbb\x9c\xe3\x80\x82\xe5\x8a\xa0\xe5\x85\xa5\xe4\xba\xba\xe4\xba\xba\xe7\xbd\x91\xef\xbc\x8c\xe6\x89\xbe\xe5\x88\xb0\xe8\x80\x81\xe5\x90\x8c\xe5\xad\xa6\xef\xbc\x8c\xe7\xbb\x93\xe8\xaf\x86\xe6\x96\xb0\xe6\x9c\x8b\xe5\x8f\x8b\xe3\x80\x82'] >>> a=s[0] >>> print 人人网,中国领先的实名制sns社交网络。加入人人网,找到老同学,结识新朋友。 

or can decode manually :

>>> print a.decode('utf-8') 人人网,中国领先的实名制sns社交网络。加入人人网,找到老同学,结识新朋友。 

Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -