pythonの角度的にフル半分の幅

def strQ2B(ustring):
    """全角转半角"""
    if not ustring:
        return ustring
    rstring = ""
    for uchar in ustring:
        inside_code=ord(uchar)
        if inside_code == 12288:                              # 全角空格直接转换
            inside_code = 32
        elif (inside_code >= 65281 and inside_code <= 65374):  # 全角字符(除空格)根据关系转化
            inside_code -= 65248
        rstring += unichr(inside_code)
    return rstring

s = "四川省乐山市市中区嘉祥路1719号6栋栋5单元10楼1号"
print(s)
b = strQ2B(strQ2B(s))
print(b)

# 四川省乐山市市中区嘉祥路1719号6栋栋5单元10楼1号

 

公開された44元の記事 ウォンの賞賛0 ビュー1897

おすすめ

転載: blog.csdn.net/weixin_39331401/article/details/104705076