Skip to content

Instantly share code, notes, and snippets.

@santagada
Created July 10, 2012 03:11
Show Gist options
  • Save santagada/3080729 to your computer and use it in GitHub Desktop.
Save santagada/3080729 to your computer and use it in GitHub Desktop.
função de digito verificador
from itertools import cycle
class A(object):
def nfe_digito_verificador(self, key):
numeros = reversed(map(int, key))
soma = sum(n * m for n, m in zip(numeros, cycle(range(2,10))))
resto = soma % 11
if resto < 2:
return 0
else:
return 11 - resto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment