Created
November 7, 2020 13:22
-
-
Save sl5net/ff5c8ead7ef7ac95fd9e3a100be6fa6c to your computer and use it in GitHub Desktop.
data["hotKey"]["hotKey"] = "<f11>"
KeyError: 'hotKey'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import json | |
home = str(Path.home()) | |
path = home + "/.config/autokey/data/Sample Scripts/" | |
jsonFilePath = home + "/.config/autokey/data/Sample Scripts/.run-run-lintalistAHK-all.json" | |
# /home/administrator/.config/autokey/data/Sample Scripts/.run-run-lintalistAHK-all.json | |
# /home/administrator.config/autokey/data/Sample Scripts/.run-run-lintalistAHK-all.json' | |
# { | |
# "hotkey": { | |
# "modifiers": [], | |
# "hotKey": "<f12>" | |
# }, | |
# } | |
with open(jsonFilePath) as f: | |
data = json.load(f) | |
data["hotKey"]["hotKey"] = "<f11>" | |
# In Python, strings are immutable, so you can't change their characters in-place. | |
with open(jsonFilePath, 'w') as f: | |
json.dump(data, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment