python 去除特殊符号

    xiaoxiao2022-07-13  145

    1.replace()

    text = "我的车牌号是粤B-34567。" text = text.replace("-","") text = text.replace("。","") print(text)

    输出:我的车牌号是粤B34567 2.split()

    text = "我的车牌号是粤B-34567。" text = ''.join(text.split('-')) text = ''.join(text.split('。')) print(text)

    输出:我的车牌号是粤B34567

    最新回复(0)