From d9a0e456d2a34fca1ac0aa3e1a5ccfe7a3bcc46d Mon Sep 17 00:00:00 2001 From: Sirin Puenggun Date: Wed, 30 Nov 2022 11:22:38 +0700 Subject: [PATCH] Initial commit --- file_read_write.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 file_read_write.py diff --git a/file_read_write.py b/file_read_write.py new file mode 100644 index 0000000..003e379 --- /dev/null +++ b/file_read_write.py @@ -0,0 +1,20 @@ +import json +import os + +def read_write_command(com): + filename = "history.json" + file_data = {} + + try: + with open(filename, "r") as file: + file_data = json.load(file) + except : + pass + + file_data = {2:com} + + with open(filename, "w") as file: + json.dump(file_data, file, indent = 4) + +def delete(): + os.remove("history.json") \ No newline at end of file