Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- keyword = {
- "shortkey":"longer sentence",
- "gm":"goodmorning",
- "etc":"etcetera"
- }
- with open('file.txt', 'r') as file:
- with open('newfile.txt', 'a') as newfile:
- lines = file.readlines()
- for line in lines:
- if 'shortkey="' in line:
- x = line.split('"')[1].split()
- if x == keyword.keys():
- for x, replacement in keyword.items():
- newfile.write(replacement)
Add Comment
Please, Sign In to add comment