![]() |
Simple Read File Issue - 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: Simple Read File Issue (/thread-24323.html) |
Simple Read File Issue - blackjesus24 - Feb-08-2020 Hi, So basically i'm trying to read something from a simple text file, and i don't really get any errors but the output is blank. Any help is appreciated :-) employee_file = open("asa.txt", "r") print(employee_file.read()) employee_file.close()
RE: Simple Read File Issue - Axel_Erfurt - Feb-08-2020 maybe the text file is empty? RE: Simple Read File Issue - blackjesus24 - Feb-08-2020 It's not... Dammit i guess it's a unique problem only on my computer, i have tried with 3 diffrent text files, still same result.. Also i have tried to "r+" and "w" still.. RE: Simple Read File Issue - Axel_Erfurt - Feb-08-2020 Did you start the script in the same directory that contains the text file? You can try the full path employee_file = "/Path/To/asa.txt" with open(employee_file, 'r') as f: print(f.read()) RE: Simple Read File Issue - blackjesus24 - Feb-09-2020 I just fixed it :D. The problem was with the software and not the actual code. I do not know why?? But after installing Submlime Text everything worked perfectly fine, i used PyCharm before. So weird... It should work either way. Thank u so much for trying to help. |