话不多说,直接贴代码:
f = open('out.txt', 'w', encoding='utf-8')
for i in range(0x0000, 0xffff + 1):
hex_str = str(hex(i))[2:]
hex_str = '0' * (4 - len(hex_str)) + hex_str
try:
f.write('{}\t0x{}\t{}\n'.format(i, hex_str, eval(r"'\u{}'".format(hex_str))))
except UnicodeEncodeError:
f.write('{}\t0x{}\t{}\n'.format(i, hex_str, '(UnicodeEncodeError)'))
f.close()
执行结果:
链接:查看请见百度网盘
提取码:798w