import re
a = 'A45198DD8856F987'
def conver(value):
matched = value.group()
# 要与整形6比较,要把字符串转换为整形.
if int(matched) >= 6:
#返回的结果是整形,变量a里面是字符串所有要把结果变成字符串
return str(9)
else:
return str(0)
r = re.sub('\d',conver ,a)
print(r)
matched = value.group()这个意思还是不太懂