Python Unicode 转 汉字

def convert(content):
    return content.encode("UTF-8").decode("Unicode_Escape")

if __name__ == "__main__":
    while True:
        content = input("请输入 Unicode 代码:")
        
        target = convert(content)
        
        print(f"\n{target}\n")
from requests import post
from bs4 import BeautifulSoup as bs


def convert(content):
    def find_data(res):
        soup = bs(res.text, "html.parser")

        target = soup.find("textarea", id="result")

        return target.text

    data = {}
    data["content"] = content
    data["untoch"] = "Unicode 转 中文"
    
    res = post("http://tool.chinaz.com/tools/unicode.aspx", data=data)
    target = find_data(res)

    return target

if __name__ == "__main__":
    while True:
        content = input("请输入 Unicode 代码:")
        
        target = convert(content)
        
        print(f"\n{target}\n")
posted @ 2020-04-03 19:25  Nefarious  阅读(222)  评论(0)    收藏  举报