python3进行汉字和unicode码的转换
时间:2018-07-02 21:07:47
收藏:0
阅读:246
输出某个unicode码对应的汉字和某个汉字对应的unicode编码。
# -*- coding=UTF-8 -*- str1 = "\u6000"#某个汉字的unicode码 str2=‘一‘#汉字一 #print(str1.encode(‘utf-8‘).decode(‘unicode_escape‘))#python2的写法,python3不能用 print(str1)#输出str1对应的汉字 print(str2.encode(‘unicode_escape‘))#输出汉字一对应的unicode编码
原文:https://www.cnblogs.com/shixisheng/p/9255744.html
评论(0)