from io import StringIO from json import load try: load(StringIO()) except ValueError as e: print(e.args[0])