pip install ipython
then launch with ipython
Can be invoked easily from iPython, using !command with args
import pathlib
pathlib.Path("myfile.txt").read_text()
import requests
requests.get("https://someurl").json()
from pprint import pprint
nicestring = pprint(somejsonstring)
with open("filepath.txt", "r") as f:
jsonobj = json.load(f)
justastring = f.read()
jsonobjfromstring = json.loads(justastring)
listoflines = f.readlines()
instead of json, we can use yaml format (pip install PyYAML
), which is basically json that uses indents and newlines instead of parentheses.
Then, we can load yaml into typical python objects (dicts and lists) as:
import yaml, pprint
dicts = yaml.safe_loads(someYamlString)
pprint(dicts)
← Back to Articles