pathon做互联网黑话解析

现在互联网上流行用缩写来表示一些词汇。比如dbq等于【对不起】,xswl等于【笑死我了】,cxk等于【蔡徐坤】等等。请构建一个黑话字典,用来将黑话还原成正常句子。

输入格式:【包含黑话的字符串,黑话】用英文逗号分隔

黑话字典:heihua_dict = {'xswl':'笑死我了','dbq':'对不起','cxk':'蔡徐坤'}

提示:

字符串split函数,将字符串根据分隔符分割成列表

字符串replace函数,可以用于替换字符串


heihua_dict = {'xswl': '笑死我了', 'dbq': '对不起', 'cxk': '蔡徐坤'}
data_str = input("请输入:")
heihua_str = data_str.strip().split(",")[0]
heihua_key = data_str.strip().split(",")[1]
print(heihua_str.replace(heihua_key, heihua_dict[heihua_key]))

img