As per this code:
# coding=utf-8
import sys
import chardet
print(sys.getdefaultencoding())
a = 'abc'
print(type(a))
print(chardet.detect(a))
b = a.decode('ascii')
print(type(b))
c = '中文'
print(type(c))
print(chardet.detect(c))
m = b.encode('utf-8')
print(type(m))
print(chardet.detect(m))
n = u'abc'
print(type(n))
x = n.encode(encoding='utf-8')
print(type(x))
print(chardet.detect(x))
I use utf-8
to encode n
but the result still show the result is ascii
.
So I want to know, what is relation between utf-8
, ascii
and unicode
.
i run with python2.
===================result=================================
=======================end result =============================