import chardet

s = 'sdffdfd'
print type(s)
print chardet.detect(s)

s2 = '反反复复'
print type(s2)
print chardet.detect(s2)

s3 = u'反反复复'.encode('utf-8')
print type(s3)
print chardet.detect(s3)

# <type 'str'>
# {'confidence': 1.0, 'encoding': 'ascii'}
# <type 'str'>
# {'confidence': 0.938125, 'encoding': 'utf-8'}
# <type 'str'>
# {'confidence': 0.938125, 'encoding': 'utf-8'}

相关文章:

  • 2021-11-14
  • 2022-03-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
猜你喜欢
  • 2021-04-28
  • 2021-06-20
  • 2021-09-08
  • 2021-10-28
  • 2021-09-02
  • 2021-08-17
  • 2022-12-23
相关资源
相似解决方案