Skip to content

Instantly share code, notes, and snippets.

@dunossauro
Last active December 14, 2018 18:21
Show Gist options
  • Save dunossauro/5918e69beb43640686aaad56c240ed29 to your computer and use it in GitHub Desktop.
Save dunossauro/5918e69beb43640686aaad56c240ed29 to your computer and use it in GitHub Desktop.
Conversão de strings em tipos válidos do python usando literal_eval
from ast import literal_eval
def convert_to_type(input_data):
try:
return literal_eval(input_data)
except (ValueError, SyntaxError):
return input_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment