Posts by Herald • 1 point
1 post
-
-2
votes5
answers7921
viewsA: How to properly format CPF in Python?
The code below accepts text and number as input: import re def format_cpf(cpf): cpf = "{:0>11}".format(int(cpf)) return re.sub("(\d{3})(\d{3})(\d{3})(\d{2})", "\\1.\\2.\\3-\\4", cpf)…