Some Codes! - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Some Codes! (/thread-31827.html) |
Some Codes! - Oshadha - Jan-05-2021 I want a code for the following things, 1. A Script that makes a new folder called MY Folder in %appdata% 2. A Script that makes a new hidden file inside %appdata% / MY Folder 3. A script that appends the hidden file, as a .txt file. And I want to read that file line by line. Example : I want to print line 3 of the txt file. 4. A script that makes sure there is an internet connection. If the internet connection is not there, I want it to trigger a Function. 5. Drop down menus in Tkinter. It would be a massive help. If the questions are not clear, please message. RE: Some Codes! - buran - Jan-05-2021 welcome to the forum. This is not how things work here. This forum is aimed at education and we are glad to help with any problems you may have with YOUR code. But we are not going to do your work for you. Not to mention that you can google all your "requests" and find sample code that you can start with and then adapt to better suit your needs. Also, it would be better to have separate threads for different problems. So, post your code in python tags, full traceback if you get any error - in error tags, ask specific questions. RE: Some Codes! - Oshadha - Jan-05-2021 (Jan-05-2021, 03:27 PM)buran Wrote: welcome to the forum. This is not how things work here. This forum is aimed at education and we are glad to help with any problems you may have with YOUR code. But we are not going to do your work for you. Not to mention that you can google all your "requests" and find sample code that you can start with and then adapt to better suit your needs. Also, it would be better to have separate threads for different problems. Owh, Sorry! I'll try to find some codes! RE: Some Codes! - Oshadha - Jan-05-2021 Whats wrong with this? import os print os.getenv('APPDATA')
RE: Some Codes! - ndc85430 - Jan-05-2021 In Python 3, print is a function.
RE: Some Codes! - Oshadha - Jan-05-2021 (Jan-05-2021, 03:36 PM)ndc85430 Wrote: In Python 3, Soo, any py 3 codes to replace it? RE: Some Codes! - ndc85430 - Jan-05-2021 You know how to call a function, right? If not, then it sounds like you need to go and learn the basics. RE: Some Codes! - DeaD_EyE - Jan-05-2021 import os from pathlib import Path appdata = os.environ.get("APPDATA") print("APPDATA:", appdata) app_directory = Path(appdata, "your_app")Just lookup what pathlib.Path does and os.environ is a dict .The get method of a dict returns the corresponding value or a None , if the key does not exist.In the case if the application should also run on Linux and Mac, use this package: https://pypi.org/project/appdirs/ Many Libraries are using this dependency, so maybe it's already installed on your system. |