参考链接:
https://blog.csdn.net/hit0803107/article/details/52885702

 

 

decode:  将其它编码转成  ===》unicode

encode:  将 unicode   ====》其它编码

 

 

 

#-*- coding:utf-8 -*-
#python 判断字符串是中文还是英文,只要有一个中文就算中文。


import sys
reload(sys)
sys.setdefaultencoding('utf8')

def check_contain_chinese(check_str):
for ch in check_str.decode('utf-8'):
if u'\u4e00' <= ch <= u'\u9fff':
return True
return False

if __name__ == "__main__":
print check_contain_chinese('i love yiu ')
print check_contain_chinese('i love you')
print check_contain_chinese('xx中国')


 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-11
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案