python--ASCII和UNICODE字符串的区别

import os
print "Input your Chinese name:"
s=raw_input("Press enter to be continued  ");
print "Your name is  : " +s;
l=len(s)
print "Length of your Chinese name in asc codes is:"+str(l);
a=unicode(s,"GBK")
l=len(a)
print "I'm sorry we should use unicode char!Characters number of your Chinese \
name in unicode is:"+str(l);

 

 

运行结果:

Input your Chinese name:
Press enter to be continued  王二毛
Your name is  : 王二毛
Length of your Chinese name in asc codes is:6
I'm sorry we should use unicode char!Characters number of your Chinese name in unicode is:3

你可能感兴趣的:(unicode)