{"id":986,"date":"2021-06-11T22:39:15","date_gmt":"2021-06-11T17:09:15","guid":{"rendered":"https:\/\/cbsepython.in\/?p=986"},"modified":"2022-01-25T11:21:42","modified_gmt":"2022-01-25T05:51:42","slug":"simple-text-editor-python-project","status":"publish","type":"post","link":"https:\/\/cbsepython.in\/simple-text-editor-python-project\/","title":{"rendered":"Simple Text Editor- Python Project for Class 12"},"content":{"rendered":"<h3>Simple Text Editor- Python Project for Class 12<\/h3>\n<p>&nbsp;<\/p>\n<p>Source Code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">#https:\/\/cbsepython.in\r\nimport sys\r\nimport os\r\nimport shutil\r\ndef leave():\r\n    sys.exit(\"You are exiting from Editor\")\r\n\r\n\r\ndef read():\r\n    try:\r\n        file_name = input(\"Enter file name: \")\r\n        target = open(file_name, \"r\")\r\n        readfile = target.read()\r\n        print(readfile)\r\n    except Exception as e:\r\n        print(\"There was a problem: %s\" % (e))\r\n\r\n\r\ndef delete():\r\n    file_name = input(\"Enter file name: \")\r\n    try:\r\n        os.unlink(file_name)\r\n    except Exception as e:\r\n        print(\"There was a problem in action: %s\" % (e))\r\n\r\n\r\ndef write():\r\n    try:\r\n        print(\"Instructions:\")\r\n        print(\"1:Enter file name to start.\")\r\n        print(\"2:Enter the text for file.\")\r\n        print(\"3: Type save in last line to save your data.\")\r\n        file_name = input(\"Enter your file name: \")\r\n        target = open(file_name, \"a\")\r\n        while True:\r\n            append = input()\r\n            target.write(append)\r\n            target.write(\"\\n\")\r\n            if append.lower() == \"save\":\r\n                break\r\n    except Exception as e:\r\n        print(\"There was a problem: %s\" % (e))\r\n\r\n\r\ndef cwd():\r\n    try:\r\n        print(os.getcwd())\r\n        change = input(\"Change Y\/N: \")\r\n        if change.startswith(\"y\"):\r\n            path = input(\"New CWD: \")\r\n            os.chdir(path)\r\n    except Exception as e:\r\n        print(\"There was a problem: %s\" % (e))\r\n\r\n\r\ndef rename():\r\n    try:\r\n        file_name = input(\"Enter current file name: \")\r\n        new = input(\"Enter new file name: \")\r\n        shutil.move(file_name, new)\r\n    except Exception as e:\r\n        print(\"There was a problem: %s\" % (e))\r\n\r\n\r\nwhile True:\r\n    print(\"===================================================\")\r\n    print(\"                 SIMPLE TEXT EDITOR\")\r\n    print(\"===================================================\")\r\n    print(\"Options: \\n write\\n read\\n cwd\\n exit\\n delete\\n rename\")\r\n    do = input(\"So, what are you wishing for today: \")\r\n    if do.lower() == \"write\":\r\n        write()\r\n    elif do.lower() == \"read\":\r\n        read()\r\n    elif do.lower() == \"delete\":\r\n        delete()\r\n    elif do.lower() == \"exit\":\r\n        leave()\r\n    elif do.lower() == \"cwd\":\r\n        cwd()\r\n    elif do.lower() == \"rename\":\r\n        rename()\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Output:<\/p>\n<pre>===================================================\r\nSIMPLE TEXT EDITOR\r\n===================================================\r\nOptions: \r\nwrite\r\nread\r\ncwd\r\nexit\r\ndelete\r\nrename\r\nSo, what are you wishing for today:<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Simple Text Editor- Python Project for Class 12 &nbsp; Source Code: #https:\/\/cbsepython.in import sys import os import shutil def leave(): sys.exit(&#8220;You are exiting from Editor&#8221;) def read(): try: file_name = input(&#8220;Enter file name: &#8220;) target = open(file_name, &#8220;r&#8221;) readfile = target.read() print(readfile) except Exception as e: print(&#8220;There was a problem: %s&#8221; % (e)) def delete(): [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-986","post","type-post","status-publish","format-standard","hentry","category-python-projects"],"_links":{"self":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/comments?post=986"}],"version-history":[{"count":0,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/posts\/986\/revisions"}],"wp:attachment":[{"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/media?parent=986"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/categories?post=986"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cbsepython.in\/wp-json\/wp\/v2\/tags?post=986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}