This is probably best done by using a function rather than trying to make the same code work in a loop. Adapting what you have:
def getconfig( x, prompt ):
try:
theconf= config[x]
except Exception:
config[x] = raw_input( prompt )
theconf= config[x]
return theconf
Then you can use it three times:
config = shelve.open(pastaConfig + '\\config.db')
ultimaRev = getconfig( 'ultimaRev', 'Digite a nova revisão: ')
ultimoIso = getconfig( 'ultimoIso', 'Digite o tag do' )
pastaIsometricosSpooler = getconfig('pastaIsometricosSpooler', 'Digite o caminho da' )
config.close()