def decimal2hex(number):
return hex(number)[2:]
def hex2unicode(hex_number_string):
return '\\u' + hex_number_string
def unicode2chinese(unicode_number):
if isinstance(unicode_number, str):
return unicode_number.encode("latin-1").decode("unicode-escape")
elif isinstance(unicode_number, bytes):
return unicode_number.decode("unicode-escape")
if __name__ == "__main__":
number = 39532
hex_number_string = decimal2hex(number)
unicode_number = hex2unicode(hex_number_string)
chinese = unicode2chinese(unicode_number)
print(chinese)