Opening Python Programs in Command Prompt Windows and Open .Txt

I know when I first started I always had trouble opening a python program in the command prompt. I was dragging and dropping the program path into the command prompt at first. That became obsolete when I had to learn how to open and read a txt file in python.

First you want to open your command prompt, go to the search bar on your windows home bar. and type command prompt.

Once your Command prompt is open if the folder your program is in is on your desktop type cd desktop.

note: if your folder is not on the desktop you will have to cd through each directory to find it. i.e cd downloads, cd folder

cd desktop.png

We are now one step closer to being in the directory we need to be in to run the python program. we just have to cd once more the the folder that our script is in.

I typed cd Folder_you_want_open you will have to type the name of what ever the folder your script is in. 

cd folder.PNG

 

Now in this folder it looks like this:

folder.PNG

I want to open python_file.py, to do this I will simply have to go back to my command prompt and type the name of the program.py

 

python file.PNG

Once the name of the script is typed in,  I am immediately prompted with “Enter File Name” The specific program I wrote here scans a list of text inputed from a .txt file and picks out specific numbers and returns an Average.

 

To open the Text document I simply have to type into the input. the _name_of_the_txt_doc.txt see how I type it in here. mbox.PNG

 

Once I click Enter this is printed back to me. python file run.PNG

 

 

Leave a comment