zoukankan      html  css  js  c++  java
  • Python 中文编码

    # -*- coding:utf-8 -*-
    # ASCII 是一种单字节的编码,可表示256个不同字符
    # 中文 在 python3 中默认用 unicode编码
    lst = ['你', 	   # str类型,unicode编码
    	str('你'), # 同上
    	u'你', # 同上
    	'你'.encode('utf-8').decode('utf-8'), # 同上
    	# encode 将 str 转为 bytes 类型,可以再用 decode 转回 str 类型
    	
    	'你'.encode('utf-8'), # b'xe4xbdxa0',utf-8编码,一个汉字 3 Byte
    	'你'.encode('gbk'), # b'xc4xe3',gbk、gbxxxx 编码,一个汉字 2 Byte
    	'你'.encode('GB2312') # 同上
    	]
    
    for word in lst:
    	print (word, type(word))
    
  • 相关阅读:
    git merge
    google platform
    http tutorial
    DS,AA tree
    Java,Hashtable
    java,Object
    Pumping lemma for regular languages
    Pumping lemma
    Context-free grammar
    Formal language
  • 原文地址:https://www.cnblogs.com/flipped/p/9616071.html
Copyright © 2011-2022 走看看