import json import os with open(os.path.expanduser("~/Desktop/code/ucloud-vm/Pipfile.lock")) as f: # content = f.read() content = json.load(f) print(content["default"].keys())