Python tutorial- save file .py extension

Save file with .py extension

So far, you have directly written your python code in python interpreter interface. When you close it, your code is lost. To keep your code in your hard drive for running it later you can use a simple text editor to write the code (e.g. Notepad) and save it with .py extension. You can run it by double-clicking the file name(with .py extension).
For example, write the following code in Notepad and save it as in your current working directory (C:\Python25):
youremail=raw_input('Enter your e-mail address:')
print 'User name:%-15s Domain: %s' % (username,domain)
By double-clicking the file name, you program will be compiled and run. However, the program will close suddenly. To avoid this problem, there are two ways. First you need to add the line of code:k=raw_input(‘Press any key to exit…’) below other lines of code.

python run save code 

Another way is to open your file with python interpreter interface and press F5 to run it.


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.