Python学习之半角转全角

狗狗听话 走在路上 / 2023-08-21 / 原文

def strB2Q(ustring):
    rstring = ""
    for uchar in ustring:
        inside_code = ord(uchar)
        if inside_code == 32:
            inside_code = 12288
        elif 32 <= inside_code <= 126:
            inside_code += 65248
        rstring += chr(inside_code)
    return rstring