import re
s = "Alex:1998,Sunny:1997"
l = re.sub(r"\W+","#",s)  # 这是大写W
print(l) # Alex#1998#Sunny#1997
f4bbad88a41e28692ee499dd51b5b134cc5810f2
<mask token>

<mask token>
print(l)

<mask token>
s = 'Alex:1998,Sunny:1997'
l = re.sub('\\W+', '#', s)
print(l)

import re
s = 'Alex:1998,Sunny:1997'
l = re.sub('\\W+', '#', s)
print(l)

import re
s = "Alex:1998,Sunny:1997"
l = re.sub(r"\W+","#",s)  # 这是大写W
print(l) # Alex#1998#Sunny#1997