富国沪深
1234567891011def get_solo(text): duels=[x+x for x in list('。,!')] #如需增加标点符号,比如问号,直接将list('。,!')换成list('。,!?')即可. for d in duels: while d in text: text=text.replace(d,d[0]) return text if __name__=='__main__': text='开开心心,,,,上上。。。好好的!!' print(get_solo(text))结果:12>>> 开开心心,上上。好好的!